Hi,
i want creat a programm with the help of c# for manipulation a data mysql database.
My code shows in these way:
Code:
private void insert_Click(object sender, EventArgs e)
{
OdbcConnection con = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;" +
"Database=knowledge;UID=C_Sharp;PWD=c_sharp;");
con.Open();
DataTable datatable = new DataTable();
OdbcCommand com = new OdbcCommand();
OdbcDataAdapter adapter = new OdbcDataAdapter();
com.Connection = con;
datatable.TableName = "product";
com.CommandText = "SELECT * FROM " + datatable.TableName + ";";
adapter.SelectCommand = com;
adapter.Fill(datatable);
com.CommandText = "INSERT INTO product(product) VALUES(\"" + Product.Text + "\");";
adapter.InsertCommand = com;
adapter.Update(datatable);
/*Testausgabe in eine zweites Textfeld des Formulares*/
text.Clear();
text.AppendText(adapter.InsertCommand.CommandText);
My probelm is, the sql-string for insert data in the database will build correctly. but after the run of the program no data was insert into the table.
I hope someone can help me to find my mistake.