oleDB C# Insert Problem with Access DB

enginious

Member
Joined
Jan 9, 2007
Messages
11
Hi,

I dont like posting on here, when Im sure its an easy answer but for some reason I cannot get the following to actually INSERT the record :

Code:
OleDbConnection myConnection = new OleDbConnection(Properties.Settings.Default.dataConnectionString);

OleDbCommand myCommand = new OleDbCommand("INSERT INTO DataLog(myData) Values(geoff)",myConnection);

myConnection.Open();
myCommand.Execute();

It executes the code without an error, and if I use ExecuteNonQuery it returns saying 1 row has been affected, but when I then view the db it has not been inserted.

Any ideas gratefully received,
Cheers,
Sparky.
 
Quick Update

Hi,

I just thought Id let anyone following this thread know that the problem is only when I am in the design suite and running the program through that. As soon as I publish the .exe it writes to the database perfectly.

Sparky.
 
Thats because youve got the mdb in your solution and that one gets copied
to the bin dir everytime you start in the IDE.

Youz can change the properties of the file to "copy never".
 
Back
Top