【发布时间】:2019-06-27 08:07:56
【问题描述】:
我是 C# 新手,我想在 Access 中插入一些 Datagridview 列,以便之后检索这些数据。
private void metroButton5_Click(object sender, EventArgs e)
try
{
OleDbConnection connection = new OleDbConnection(@"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = F:\Database\DBAdatabase.accdb; Persist Security Info = False; ");
for (int s = 0; s < dataGridView1.Rows.Count - 1; s++)
{
OleDbCommand command = new OleDbCommand(@"INSERT INTO Quotations (Position, LVPosition)VALUES('"+dataGridView1.Rows[s].Cells[0].Value+"','"+dataGridView1.Rows[s].Cells[1].Value+"')", connection);
connection.Open();
command.Connection = connection;
command.ExecuteNonQuery();
MessageBox.Show("Data Saved");
connection.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
我变成了 Error Systen.Data.OleDb.OleDbException (0x80040E14): Syntaxerror in the Insert Into。
谁能帮我解决它.....
非常感谢..
我也参考了这个链接(https://www.youtube.com/watch?v=8hCfje5VL-0&ab_channel=codefactory2016),但我找不到错误原因。
【问题讨论】:
-
欢迎来到 SO!请收下tour 并阅读How to Ask。
标签: c# datagridview ms-access-2016