Alessandro Cifani Alessandro Cifani - 7 months ago 10
SQL Question

Data type mismatch when calling ADO Open Method with a Session variable

Here's the code on my

index.asp
page

If Session("SQL") <> "" Then
SQL=Session("SQL")
Session("SQL")=""
Set Recordset=Server.CreateObject("ADODB.Recordset")
Recordset.Open SQL, Connection <------------
Do until Recordset.EOF
...


and here's the code where i get the
Session("SQL")
from, on another page (
tabselect.asp
)

If SelArtista <> "0" Then
Session("SQL") = "SELECT ..."
Else
Session("SQL") = "SELECT ..."
End If


I get this error on the line I pointed with the arrow on the code above


Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

Answer

The error was in the string I used as SQL query. I had ' around numbers and the engine didnt read them correctly. I just had to remove them and the problem's gone.

Comments