If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Autonumber problem Error "Data type mismatch in criteria expression"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-22-02, 06:00
jvdzwaan jvdzwaan is offline
Registered User
 
Join Date: Nov 2002
Posts: 10
Question Autonumber problem Error "Data type mismatch in criteria expression"

Hi All,

I am already busy for several hours on this problem WHO CAN HELP ME ;(
I got a Access database with with the field "Password", "Title", And the field PMID (PMID is a AUTONUMBER FIELD in ACCESS 1,2,3,4,5,6,7)

I got this script
SQL = "Select Title, Password From Checklist " _
& "Where Title = '"&Title&"' And Password = '"&Password&"'"
Set RS = MyConn.Execute(SQL)

THIS WORKS GREATTTTTTTTTTTTTTT!!!!!!!!!
But now here it comes.
I want to change TITLE to PMID in this script.

SQL = "Select PMID, Password From Checklist " _
& "Where PMID = '"&PMID&"' And Password = '"&Password&"'"
Set RS = MyConn.Execute(SQL)

Know i think is should remove the singel '. So i did that. I canged the script to
SQL = "Select PMID, Password From Checklist " _
& "Where PMID = #" & PMID & "# And Password = '"&Password&"'"
Set RS = MyConn.Execute(SQL)

But i keep getting errors like
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression 'PMID = ## And Password = 'test''.
/pm/login.asp, line 17

It seems that it doesn't reed the PMID...
WHO CAN HELP ME ?
__________________
just joost :-)
Reply With Quote
  #2 (permalink)  
Old 11-22-02, 08:49
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Autonumber problem Error "Data type mismatch in criteria expression"

This is not a SQL problem - it looks to me like your VBScript VARIABLE called PMID is empty. Try putting this debug message in your code instead of the Execute:

Response.Write( "PMID = " & PMID )

I'll bet when you run it you see this:

PMID =

So the problem is you need to assign a value to PMID.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 11-22-02, 09:02
jvdzwaan jvdzwaan is offline
Registered User
 
Join Date: Nov 2002
Posts: 10
Hi andrewst

You Are right , It is emty then... How is this posible.

How so i fix that. THis field is a AUTONUMBER.
And there are numbers in it....

When i look in Access and go with the DESIGNS VIEW
to the "PMID" field. It tells me this properties:
- Field Size : Long Integer
- New Values : Increment
- Format :
- Caption :
- Indexed : YES (No Duplicades)

When i look in the normal VIEW in the table PMID it give just the normal Numbers automaticly generated. 1,2,3,4,5,6,7,8,9,10... until 86
__________________
just joost :-)
Reply With Quote
  #4 (permalink)  
Old 11-22-02, 09:05
jvdzwaan jvdzwaan is offline
Registered User
 
Join Date: Nov 2002
Posts: 10
Re: Autonumber problem Error "Data type mismatch in criteria expression"

PS
Here is the whole script

----------------------------------------------------
<HTML>
<BODY>

<%
PMID = Request.Form("ID")
Password = Request.Form("passw")
'grab the form contents

Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open ("problemman")

SQL = "Select PMID, Password From Checklist " _
& "Where PMID = " & PMID & " And Password = '"&Password&"'"
Set RS = MyConn.Execute(SQL)

If Not RS.EOF Then
Session("allow") = True
'if there is a match then show the page
%>

<html>
'HERE IS MY HTML PAGE
</html>

<%
Else
Response.Redirect "http://www.testl.com/main.htm"
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
End If
%>

</BODY>
</HTML>
__________________
just joost :-)
Reply With Quote
  #5 (permalink)  
Old 11-22-02, 09:12
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
Originally posted by jvdzwaan
Hi andrewst

You Are right , It is emty then... How is this posible.

How so i fix that. THis field is a AUTONUMBER.
And there are numbers in it....

When i look in Access and go with the DESIGNS VIEW
to the "PMID" field. It tells me this properties:
- Field Size : Long Integer
- New Values : Increment
- Format :
- Caption :
- Indexed : YES (No Duplicades)

When i look in the normal VIEW in the table PMID it give just the normal Numbers automaticly generated. 1,2,3,4,5,6,7,8,9,10... until 86
Yes, but the problem has nothing to do with the COLUMN called PMID in the table, it is to do with the VBSCript VARIABLE that happens to have the same name. The variable is not AUTONUMBER, it is just a variable. If you don't assign a value to it, it will not get one for itself!
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #6 (permalink)  
Old 11-22-02, 09:14
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Autonumber problem Error "Data type mismatch in criteria expression"

Quote:
Originally posted by jvdzwaan
PS
Here is the whole script

----------------------------------------------------
<HTML>
<BODY>

<%
PMID = Request.Form("ID")
Password = Request.Form("passw")
'grab the form contents

Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open ("problemman")

SQL = "Select PMID, Password From Checklist " _
& "Where PMID = " & PMID & " And Password = '"&Password&"'"
Set RS = MyConn.Execute(SQL)

If Not RS.EOF Then
Session("allow") = True
'if there is a match then show the page
%>

<html>
'HERE IS MY HTML PAGE
</html>

<%
Else
Response.Redirect "http://www.testl.com/main.htm"
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
End If
%>

</BODY>
</HTML>
So the question is: why has the field called "ID" in the form not been populated? Is this field displayed? Did you type a value into it before hitting Submit?
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #7 (permalink)  
Old 11-22-02, 09:30
jvdzwaan jvdzwaan is offline
Registered User
 
Join Date: Nov 2002
Posts: 10
yes... I got a form with 2 fields
one called ID
and one called passw

when i fill in the form I entered for the ID 61 (is in the DB)
in the passw field i entered test

Then i get the error

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

/PM/login.asp, line 14
__________________
just joost :-)
Reply With Quote
  #8 (permalink)  
Old 11-22-02, 09:51
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
Originally posted by jvdzwaan
yes... I got a form with 2 fields
one called ID
and one called passw

when i fill in the form I entered for the ID 61 (is in the DB)
in the passw field i entered test

Then i get the error

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

/PM/login.asp, line 14
So have you solved the variable problem yet? I mean, if you put:

Response.Write "PMID = " & PMID

in your program, does it now say:

a) PMID = 61

or:

b) PMID =

If the answer is still (b) then you are sure to get an error since the SQL you send to Access is:

Select PMID, Password From Checklist Where PMID = And Password = 'test'

which is invalid. In this case, you need to debug the variable assignment, not the SQL!

If it seems OK, then try writing out the whole SQL statement:

Response.Write SQL

and see if it a sensible SQL statement.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On