我正在尝试使用一些数据填充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();
}
答案 0 :(得分:2)
// add named parameters
cmd.Parameters.AddRange(new OleDbParameter[]
{
new OleDbParameter("@code", code),
new OleDbParameter("@date", date),
new OleDbParameter ("@percent", newVar)
}; // <-- missing parenthesis.