我正在尝试用一些数据填充 Access 表。问题是我在某处丢失了一个括号,我真的不知道丢失的括号应该在哪里。
OleDbConnection MyConn = new OleDbConnection(ConnStr);
MyConn.Open();
using (OleDbCommand cmd = MyConn.CreateCommand())
{
// create command with placeholders
cmd.CommandText =
"INSERT INTO MasterTable "+
"([Code], [Date], [Percent]) "+
"VALUES(@code, @date, @percent)";
// Add named parameters
cmd.Parameters.AddRange(new OleDbParameter[]
{
new OleDbParameter("@code", code),
new OleDbParameter("@date", date),
new OleDbParameter ("@percent", newVar)
};
// Execute
cmd.ExecuteNonQuery();
}