Inserting data into Access database
Hi Forum,
This code compiles and executes just fine, except the data is not inserted into the database. I think I need to make a commitment of some kind to finalize the transaction.
public void insertRow( Object s, EventArgs e )
{
OleDbCommand cmd;
String cmdString;
String formValues;
formValues = Email.Text + "," +
Church.Text + "," +
Name.Text + "," +
Comments.Text;
cmdString = "INSERT INTO GuestBook [VisitDate] VALUES (" + formValues + ")";
connectDb();
cmd = new OleDbCommand( cmdString, objConn );
try{
// not sure what to put here
}/*catch( Object s ){
// Handle error not sure what to do
}*/
finally {
// not at all sure what to do next to commit transaction
}
objConn.Close();
}// End insertRow()
Thanks
|