borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Save and Load Database)Next Topic (Shorting alphabetically the contents of a DataGrid control) New Topic New Poll Post Reply
AndreaVB Forum : VB General : My AdoDc control insists on updating a field in my data base !
Poster Message
iliekater
Level: Master

Registered: 04-02-2005
Posts: 122

icon My AdoDc control insists on updating a field in my data base !

Lately I decided to change the code in a program of mine that uses an AdoDc control to connect to an Acces data base and also a DataGrid control in order to show the contents of the data base file (of a specific table , ofcourse) .
I wanted to change the code , becoue up to now it was designed for the AdoDc control to connect to a specified file , that is the path always being the same . But since the program will be installed in various computers and each user may decide to install on a different path , I no longer can rely on a static path .
Thus , instead of assigning manually the properties the AdoDc controls (connection string , record source etc) , I have to do that by code .
First , when the program is firstly loaded , I hav a routine that determines the installation path (I call the variable ontaining the path Motherpath !) .
So , when the form containing the AdoDc control is loaded , the program already knows its installation path and the path of the data base file (MotherPath & "\Resourses\DataBases\Customers.mdb) .
Up to now , I haven't noticed any problem .
Here's the code at the Load section of the form :
Private Sub Form_Load()
  DataBaseString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MotherPath & "\Resourses\DataBases\Customers.mdb;Mode=ReadWrite;Persist Security Info=False"
  AdodcCUSTOMERSDATA.ConnectionString = DataBaseString
  AdodcCUSTOMERSDATA.CommandType = adCmdTable
  AdodcCUSTOMERSDATA.RecordSource = "Table_Customers"
  AdodcCUSTOMERSDATA.Refresh
  '''
  TextBoxDEBUGSOURCE.Text = DataBaseString
End Sub


As far as concerning the AdoDc control itself on the form , it has no property set manually (in fact I deleted the old one and added a new one in order to be sure) .

There has to be something wrong in the above code , becouse when the program runs and the form is loaded , though the DataGrid is populated susscesfully , the program tries to change the value in row 0 and column 0 of the DataGrid ! What in the world makes it believe I want that ? ! Here's a photo indicating that :



I managed to take the snapshot so that the cursor is also visible within the cell . I can't understand why this is happening . There are also 2 things : 1) The DataGrid is set to not allow Write , only allow Read of the data base file ; 2) The value that the prigram tries to change is actually from the ID field of the table of the data base , which means it can't changed eitherway .
In fact , if I try clicking on any row in the DataGrid control , I get the following error message :



Which sais :
"Cannot update 'ID' . The field is not updateable .

Anyone knows what's going on ?

13-05-2007 at 12:10 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : My AdoDc control insists on updating a field in my data base !
Previous Topic (Save and Load Database)Next Topic (Shorting alphabetically the contents of a DataGrid control) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder