Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I get this error "datatype mismatch in criteria expression" in my sql query. One of datatype in my Acceess database is declare as "Number-Long Integer".

 

This cause error occur while the datatype mismatch. I'm using asp.net with vbscript to code my page. In my sql query, there is a condition.

 

CodeBehind:

 

Dim strabc as (Integer/Long/Short/Single,Int32,Int64/Byte...)<- I had try all of this data type but still error!

 

strabc = CType(textbox.text,Integer/...)

Query = "Select * from table where abc = '" & strabc & "'"

 

Microsoft Access Data Type:

abc - Number-Long Integer

 

It is easy to use if I declare abc in DB as "Text". IS ANYONE KNOW HOW TO SOLVE IT??? what should delare the variable in my code behind page??

 

Thank you very much

 

Calvin

Posted

Query = "Select * from table where abc = '" & strabc & "'"

 

Take away the single quotes

 

Query = "Select * from table where abc = " & strabc

 

Dim strabc as Long

 

You don't have to Ctype unless you have option strict on

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...