I have three fields called fileName,rowNo and rowText in Access 07 table named shortNotes. When I run this insert query it works perfect:
thisCommand.CommandText = "insert into shortNotes values('" + fName + "'," + rNo + ",'" + richTextBox2.Text +" |"+rNo+ "')";
But when I added parameters, It started throwing this error: "data type mismatch in Criteria Expression"
Here is the code:
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
Here file is memo, rno is number and rowtext is memo datatype in access 07. What is the problem?