Hello
I have just installed the MySQLDirect.net on my machine. I am currently writing an pplication in c#. I know the syntax for inserting records into a table, but I am wondering if there is a specific way of doing it, if I am connected via mySQLDirect.net. The code that I have written is not working. Please help me.
Ade
Syntax for Insert into Table
You can use MySqlCommandBuilder component. MySqlCommandBuilder provides a means of automatically generating single-table commands used to reconcile changes made to a DataSet or DataTable with the associated MySQL server database.
Code: Select all
MySqlConnection connection = new MySqlConnection("host=localhost;database=test;user id=root");
connection.Open();
try
{
MySqlDataAdapter adapter = new MySqlDataAdapter("select * from dept", connection);
MySqlCommandBuilder commandBuilder = new MySqlCommandBuilder(adapter);
DataTable table = new DataTable("dept");
adapter.Fill(table);
// insert, update, delete rows here
table.Rows.Add(new object[] {1000,"a","b"});
adapter.Update(table);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
connection.Close();
}
Last edited by Serious on Mon 18 Apr 2005 07:30, edited 1 time in total.