narrator Posted May 14, 2011 Share Posted May 14, 2011 Hi, could someone please help with the following error:Microsoft JET Database Engine error '80040e07'Data type mismatch in criteria expression./mytest.asp, line 23 In my code below, I need to do 2 things- Use a variable passed from a form to choose the record ID, hence recid- Create a variable for the field data myTxtThe code works when I substitute 3 for recid in the sql line.recid=3set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "myDBpath"set rs=Server.CreateObject("ADODB.recordset")sql="SELECT ID, myTxt FROM myTable WHERE ID=recid" <This is the line the error refers to.rs.Open sql, connjobid=rs.fields("ID")jobtxt=rs.fields("myTxt")response.write(jobid & "<br>" & jobtxt) Link to comment Share on other sites More sharing options...
narrator Posted May 14, 2011 Author Share Posted May 14, 2011 Fixed it by changing the sql line to end in this:...WHERE ID="&recid&""But is that the right way to do it, or is there an easier way?Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.