I am having a strange problem with ASP. Whenever I build an SQL query using a text field with text in it, I get and error "[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.". The underlying table uses a text field, and I have tried cStr thru various methods in the ASP page to no avail. AS long as numbers only are entered, it works. I am comparing data to a session variable. Can anyone help? Here is the initial code for one of the datasets.

Set rsCEMData = Server.CreateObject("ADODB.Recordset")
rsCEMData.ActiveConnection = MM_connApp_STRING
rsCEMData.Source = "SELECT * FROM tblCustResults WHERE fldSampNum = " + Replace(rsCEMData__MMColParam, "''", "''''") + " AND fldCN = " + Replace(rsCEMData__MMColParam2, "''", "''''") + " AND fldSerial = " + Replace (cStr(rsCEMData__MMColParam3), "''", "''''") + ""
rsCEMData.CursorType = 0
rsCEMData.CursorLocation = 2
rsCEMData.LockType = 1
rsCEMData.Open()

Here is how I set the variables:

Dim rsCEMData2__MMColParam3
rsCEMData2__MMColParam3 = "1"
If (Session("VarSerial") <> "") Then
rsCEMData2__MMColParam3 = Cstr(Session("VarSerial"))

Any help is greatly appreciated!!

-----------------------------
This message is posted by http://asp.forumszone.com