我在名为 shortNotes 的 Access 07 表中有三个名为 fileName、rowNo 和 rowText 的字段。当我运行这个插入查询时,它工作得很好:
thisCommand.CommandText = "插入shortNotes值('" + fName + "'," + rNo + ",'" + richTextBox2.Text +" |"+rNo+ "')";
但是当我添加参数时,它开始抛出这个错误:“标准表达式中的数据类型不匹配”
这是代码:
dbCon = new OleDbConnection(MyconnectionString);
dbCon.Open();
thisCommand = new OleDbCommand();
thisCommand.Connection = dbCon;
thisCommand.Parameters.Add("@rowtext", OleDbType.BSTR);
thisCommand.Parameters.Add("@file", OleDbType.BSTR);
thisCommand.Parameters.Add("@rno", OleDbType.Integer);
thisCommand.Parameters["@rowtext"].Value = richTextBox2.Text + " |" + rNo;
thisCommand.Parameters["@file"].Value = fName;
thisCommand.Parameters["@rno"].Value = rNo;
thisCommand.CommandText = "insert into shortNotes values(@file,@rno,@rowtext)";
thisCommand.ExecuteNonQuery();//Error
这里file是memo,rno是number,rowtext是access 07中的memo数据类型。有什么问题?