我编写代码以插入一些值以使用 C#/ado.net 访问数据库,但出现了一个名为“连接错误”的错误,尽管我使用 select 命令在同一程序中检索一些值并成功运行
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Mohamed\documents\visual studio 2012\Projects\Library Store\Library Store\Book.accdb");
conn.Open();
OleDbCommand cmd = new OleDbCommand("INSERT INTO Store VALUES (@val1,@val2,@val3,@val4,@val5,@val6)", conn);
cmd.Parameters.AddWithValue("@val1", ISBNTB.Text.Trim());
cmd.Parameters.AddWithValue("@val2", NameTB.Text.Trim());
cmd.Parameters.AddWithValue("@val3", GategoryTB.Text.Trim());
cmd.Parameters.AddWithValue("@val4", AuthorTB.Text.Trim());
cmd.Parameters.AddWithValue("@val5", int.Parse(CostTB.Text.Trim()));
cmd.Parameters.AddWithValue("@val6", dateTimePicker1.Text);
cmd.ExecuteNonQuery();
MessageBox.Show(" Done :)");
conn.Close();
谢谢;