Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

problem insert into access DB

Mar 7 2003 4:50 PM
Hi I'm trying to insert into access DB this data using this code is any one can explain what is wrong with this code ???? the code : --------------------------------------------------------------------------------------- OleDbConnection connection = new OleDbConnection(strDBConn); OleDbTransaction transaction; String sql = "INSERT INTO TblProjects (field1, field2, field3, field4, field5)" + " VALUES ('" + txtbx_ProjectName.Text + "','" + ddlst_SystemsType.SelectedItem.Text + "','" + ddlst_Versions.SelectedItem.Text + "','" + ddlst_Tester.SelectedItem.Text + "','" + ddlst_ProjectManager.SelectedItem.Text + "');"; connection.Open(); transaction = connection.BeginTransaction(); st = sql; OleDbCommand commmand = new OleDbCommand(sql, connection); commmand.CommandType = CommandType.Text; commmand.Transaction = transaction; commmand.ExecuteNonQuery(); transaction.Commit(); connection.Close(); Response.Redirect("aspPage.aspx"); --------------------------------------------------------------------------------------- the exception is : Operation must use an updateable query. --------------------------------------------------------------------------------------- the SQL is: INSERT INTO TblProjects (field1, field2, field3, field4, field5) VALUES ('aaa','bbb','ccc','ddd','eee');

Answers (10)