SQL DB not savign new data row.

padsurfer

New member
Joined
Nov 17, 2006
Messages
2
Location
Burghclere, UK
Programming Experience
Beginner
I'm in the progress of trying to learn the basics of ADO.net with a simple test app, which im playing with using VB express addition. I'm having a problem which im hoping someone can help me out with.

In the following code:

cmd.CommandText =
"INSERT INTO People (Firstname,Lastname) VALUES _('Hope', 'Goodie')"
iRowsaffected = cmd.ExecuteNonQuery()
MessageBox.Show(iRowsaffected)

i also get a text box saying 1, which means that the row has been added.
Straight after this (in runtime) i then populate a listbox with these table records and my new addition is listed. I think great all good so far, however
when i end the runtime, and check the database it has no record of the last
addition i created during runtime. Can anyone tell me why, and how i can change this so it does.

Thankyou.


 
Resolved

It seems as though the issue has been resolved on another app i have started. Im not sure what it was, but i think it had something to do with the way i set the connection string...

Cant be sure.
 
I reckon youre using a file based database, like an access or sqls .mdf db.. The file is copied to the project source folder, and is set o be copied out every time the project is built. You press play, the exe is built, the exe and a new copy of the db is copied out to the DEBUG or RELEASE folder, you update this new copy, but when you try and look for the changes, youre actually lookng in the original db, which hasnt been changed because it never is


Its like having a word document on C: drive, copying it to a removable disk, editing the copy on the removable disk, then going and looking at the original and wondering where your edits went..
 
Back
Top