gamedev

gamedev

  • NA
  • 6
  • 0

add a new row, what do i wrong?

Feb 4 2005 9:22 AM
I'm tring to add a row at my database .mdb but i get the follow error: "Sintax error in the INSERT INTO instruction" why? what do i wrong? this is the schema of my database: Nome: text 15 Domanda: text 20 Risposta: text 15 Email: text 20 this is the code: System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(); conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + @"Data source= myDatabase.mdb;"; try { conn.Open(); OleDbDataAdapter myAdapter = new OleDbDataAdapter("SELECT * FROM myTable", conn); OleDbCommandBuilder myCmd = new OleDbCommandBuilder(myAdapter); DataSet myDataSet = new DataSet("myTable"); myAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; myAdapter.Fill(myDataSet, "myTable"); DataRow myRow = myDataSet.Tables["myTable"].NewRow(); myRow["Nome"] = mNuovoUtente.mName; myRow["Domanda"] = mNuovoUtente.mQuestion; myRow["Risposta"] = mNuovoUtente.mAnswer; myRow["Email"] = mNuovoUtente.mEmail; myDataSet.Tables["TabellaUtente"].Rows.Add(myRow); myAdapter.Update(myDataSet, "myTable"); catch(Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); }

Answers (2)