Insert a record via adapter

Help
wildborn
2005-07-18
2013-04-09
  • wildborn
    wildborn
    2005-07-18

    I'm a beginner of MySql and the MySqlDriverCS. I have tried to insert a record via a DataAdapter. I know the adapter.InsertCommand (see code) is wrong. Can someone help me?

    DataRow row = ds.Tables["valor"].NewRow();
                row["id"] = txtID.Text;
                row["valorenbez"] = txtBez.Text;
                row["kurs"] = txtKurs.Text;
                ds.Tables["valor"].Rows.Add(row);
                MySQLConnection DBConn;
                DBConn = new MySQLConnection(new MySQLConnectionString("localhost", "asset", "root", "pwd").AsString);
               
                MySQLInsertCommand insCom = new MySQLInsertCommand(DBConn, new object[,] {{"id",txtID.Text}, {"valorenbez",txtBez.Text},
                                                                                            {"kurs",txtKurs.Text}}, "valor");

                MySQLDataAdapter adapValor = new MySQLDataAdapter();
                adapValor.InsertCommand=insCom;
                DBConn.Open();
                adapValor.Update(ds, tabValor);
                DBConn.Close();