Every one i write code that insert some data into Microsoft Access database but i have an error "Syntax error in insert into statement" i don't know why !!! Any one help me ? thanks in advance ; code:
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\me\Library Store\Library Store\Store.accdb");
try
{
conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = "INSERT INTO Libarary ( ISBN, Name, Gategory, Author, Cost, Date) VALUES ( @ISBN, @Name, @Gategory, @Author, @Cost, @Date) ";
cmd.Parameters.AddWithValue("@ISBN", ISBNTB.Text);
cmd.Parameters.AddWithValue("@Name", NameTB.Text);
cmd.Parameters.AddWithValue("@Gategory", GategoryTB.Text);
cmd.Parameters.AddWithValue("@Author", AuthorTB.Text);
cmd.Parameters.AddWithValue("@Cost", int.Parse(CostTB.Text));
cmd.Parameters.AddWithValue("@Date", dateTimePicker1.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Data Added!");
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
