-3

我正在尝试用一些数据填充 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();
  }
4

1 回答 1

2
   // add named parameters
   cmd.Parameters.AddRange(new OleDbParameter[]
   {
       new OleDbParameter("@code", code),
       new OleDbParameter("@date", date),
       new OleDbParameter ("@percent", newVar)
   }; // <-- missing parenthesis.
于 2012-12-20T16:31:33.580 回答