Ado.net - trouble with updating my database in msaccess

kyoshiro

Active member
Joined
Jan 20, 2008
Messages
30
Programming Experience
Beginner
i having trouble with updating my database in msaccess, how do i use oledbcommandbuilder can someone helps me?
this is my code listing:
(i just assume that this will update my database )

con.Open()

Dim cb As New OleDb.OleDbCommandBuilder(adap)
adap.Fill(ds, "tblLogin")
ds.Tables("tblLogin").Rows(2).Delete()


cb.GetUpdateCommand()

adap.Update(ds, "tblLogin")
con.Close()



but when i try to look at my database it does not change!
thanks in advance
 
Last edited:
First of all you can get rid of this line:
VB.NET:
cb.GetUpdateCommand()
That is not doing anything useful.

Secondly, that code is doing exactly what it's supposed to do. You're just looking in the wrong place. Change this code:
VB.NET:
adap.Update(ds, "tblLogin")
to this:
VB.NET:
MessageBox.Show(adap.Update(ds, "tblLogin").ToString(), "Rows Affected")
If the message tells you that more than zero rows were affected then you know it's working and you're just looking in the wrong place.
 
it still not working. the messagebox tells "0 rows affected ":

this is what i did:
first i connect to a database using the tool menu >connect to database
second i use the dataadapter wizard
third i created an untyped dataset using the dataset wizard

then i try if my database will be updated using the code above..

i did what you told me but it still didnt work..

can you advise me bout this
 
its now ok. but one more problem , when i looked in my database it still not modified.

this is what i did before coding:
first i connect to the database : Tools>Connect to Database
secondly i created a oledbdataadapter using the wizard
third i created dataset using the wizard

and i did what you had told me; i modified my codes:

but it still not work!
 
thanks jmcilhinney , thanks a lot , i will try to comprehend this at my very best,
hope that you will not refuse in answering my questions. thanks a lot.
 
Back
Top