4
Reply

Trying to update data in an Access database from text boxes

Rao Varrey

Rao Varrey

Oct 11 2017 3:44 AM
149
private void button1_Click(object sender, EventArgs e)
{
// Saves changes made in the details
OdbcConnection myConnection = new OdbcConnection();
OdbcCommand cmd = myConnection.CreateCommand();
string myConnectionString = @"Driver={Microsoft Access Driver (*.mdb)};" + "Dbq=C:/DROPS-Data/Derrick.mdb";
myConnection.ConnectionString = myConnectionString;
myConnection.Open();
cmd.CommandText = "UPDATE InspInfo SET CompanyName =" + textBox1.Text + "," + "CustomerRef =" + textBox2.Text + ", Contact =" +textBox3.Text + ", RigName =" + textBox4.Text + ", Location =" + textBox5.Text + " WHERE WONo =" + textBox6.Text ;
cmd.ExecuteNonQuery();
myConnection.Close();
}
 
This is a windows project ,,,trying to update the connected database from the changes in the text boxes in the form....
 
Getting an error
 

System.Data.Odbc.OdbcException (0x80131937): ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression

Can anyone please help 
 

Upload Source Code  Select only zip and rar file.
Answers (4)