Im trying to make a method where I can insert data into a table.
I have created a database called "csharp" and a table called "test"
So far my code looks like this:
I get an error sayingpublic void Opdater()
{
MySqlConnection connection = new
MySqlConnection("host=localhost;database=csharp;user id=root; password=*******");
connection.Open();
try
{
MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT * FROM test", mySqlConnection1);
MySqlCommandBuilder commandBuilder = new MySqlCommandBuilder(adapter);
DataTable table = new DataTable("test");
adapter.Fill(table);
table.Rows.Add(new object[3]{
textBox2.Text,
textBox3.Text,
textBox4.Text});
adapter.Update(table);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
mySqlConnection1.Close();
}
}
Everytime I run the program and fill in the textboxes.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'by, tlf) VALUES ('Jakob', 'Odense', 62621894)' at line 1
Could someone alittle more skilled see where the problem is?
Thanks
AxCx