|
 |
asp_databases thread: RE: Integers and values...argh.. =/
Message #1 by "Drew, Ron" <RDrew@B...> on Tue, 2 Apr 2002 12:01:20 -0500
|
|
SQL =3D "SELECT * FROM Members WHERE id =3D " & userid & ";"
No quotes around userid...also I would change the variable to something
like struserid...userid is a reserved word in many systems.
dim struserid
struserid =3D Request.QueryString("id")
if struserid =3D "" Then
Response.Redirect "default.asp"
End If
SQL =3D "SELECT * FROM Members WHERE id =3D " & struserid & ";"
-----Original Message-----
From: SD-Studios [mailto:info@s...]
Sent: Tuesday, April 02, 2002 10:11 AM
To: ASP Databases
Subject: [asp_databases] Integers and values...argh.. =3D/
Hi!
I've gotten this very simple, but a painintheass-error.
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression.
/cdos/a_profile.asp, line 17
What have I done wrong? Request.QueryString("id") is in this case an
integer and the id-field in the database is the counter and key-thing..
=3D) Please help me out here!! Thanks! Here is my code and line 17 is
objRS.Open SQL,objCon:
userid =3D Request.QueryString("id")
If userid =3D "" Then
Response.Redirect "default.asp"
End If
Set objCon =3D Server.CreateObject("ADODB.Connection")
Set objRS =3D Server.CreateObject("ADODB.Recordset")
objCon.Open "Driver=3D{Microsoft Access Driver (*.mdb)};dbq=3D" &
Server.MapPath("db/db.mdb")
SQL =3D "SELECT * FROM Members WHERE id =3D '" & userid & "'" objRS.Open
SQL,objCon
username =3D objRS("username")
name =3D objRS("name")
surname =3D objRS("surname")
email =3D objRS("email")
age =3D objRS("age")
country =3D objRS("country")
gender =3D objRS("gender")
city =3D objRS("city")
occupation =3D objRS("occupation")
homepage =3D objRS("homepage")
icq =3D objRS("icq")
visits =3D objRS("visits")
datum =3D objRS("date")
lastvisit =3D objRS("date_time")
--
Martin Johansson,
CEO & Project Supervisor
SD-Studios
+46 (0)70-3003320
http://www.sd-studios.com
Message #2 by "CLINTON PARSLEY" <cparsley@m...> on Tue, 02 Apr 2002 08:48:07 -0700
|
|
Your getting this error because your saying you want all fields where your
id is a String by using the WHERE id = '" & userid & "'";however your id
field in the database is an integer. Try replacing this line:
SQL = "SELECT * FROM Members WHERE id = '" & userid & "'"
with this:
SQL = "SELECT * FROM Members WHERE id = " & userid
hth,
Clint
::Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
::[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in
::criteria expression.
::/cdos/a_profile.asp, line 17
::What have I done wrong? Request.QueryString("id") is in this case an
::integer and the id-field in the database is the counter and key-::thing..
::userid = Request.QueryString("id")
::If userid = "" Then
::Response.Redirect "default.asp"
::End If
::Set objCon = Server.CreateObject("ADODB.Connection")
::Set objRS = Server.CreateObject("ADODB.Recordset")
::objCon.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" &
::Server.MapPath("db/db.mdb")
::SQL = "SELECT * FROM Members WHERE id = '" & userid & "'"
::objRS.Open SQL,objCon
_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
Message #3 by "Peter Foti (PeterF)" <PeterF@S...> on Tue, 2 Apr 2002 10:59:34 -0500
|
|
If the field is a text field in the database, you must surround it with
single quotes. If it's numeric, you must NOT surround it with quotes.
Change this line:
SQL = "SELECT * FROM Members WHERE id = '" & userid & "'"
to this:
SQL = "SELECT * FROM Members WHERE id = " & userid
Regards,
Pete
> -----Original Message-----
> From: SD-Studios [mailto:info@s...]
> Sent: Tuesday, April 02, 2002 10:11 AM
> To: ASP Databases
> Subject: [asp_databases] Integers and values...argh.. =/
>
>
> Hi!
> I've gotten this very simple, but a painintheass-error.
>
> Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
>
> [Microsoft][ODBC Microsoft Access Driver] Data type mismatch
> in criteria
> expression.
>
> /cdos/a_profile.asp, line 17
>
> What have I done wrong? Request.QueryString("id") is in this
> case an integer
> and the id-field in the database is the counter and
> key-thing.. =) Please
> help me out here!! Thanks!
> Here is my code and line 17 is objRS.Open SQL,objCon:
>
> userid = Request.QueryString("id")
> If userid = "" Then
> Response.Redirect "default.asp"
> End If
>
> Set objCon = Server.CreateObject("ADODB.Connection")
> Set objRS = Server.CreateObject("ADODB.Recordset")
>
> objCon.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" &
> Server.MapPath("db/db.mdb")
> SQL = "SELECT * FROM Members WHERE id = '" & userid & "'"
> objRS.Open SQL,objCon
>
> username = objRS("username")
> name = objRS("name")
> surname = objRS("surname")
> email = objRS("email")
> age = objRS("age")
> country = objRS("country")
> gender = objRS("gender")
> city = objRS("city")
> occupation = objRS("occupation")
> homepage = objRS("homepage")
> icq = objRS("icq")
> visits = objRS("visits")
> datum = objRS("date")
> lastvisit = objRS("date_time")
> --
> Martin Johansson,
> CEO & Project Supervisor
> SD-Studios
> +46 (0)70-3003320
> http://www.sd-studios.com
>
>
>
Message #4 by "SD-Studios" <info@s...> on Tue, 2 Apr 2002 17:10:59 +0200
|
|
Hi!
I've gotten this very simple, but a painintheass-error.
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression.
/cdos/a_profile.asp, line 17
What have I done wrong? Request.QueryString("id") is in this case an integer
and the id-field in the database is the counter and key-thing.. =) Please
help me out here!! Thanks!
Here is my code and line 17 is objRS.Open SQL,objCon:
userid = Request.QueryString("id")
If userid = "" Then
Response.Redirect "default.asp"
End If
Set objCon = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
objCon.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" &
Server.MapPath("db/db.mdb")
SQL = "SELECT * FROM Members WHERE id = '" & userid & "'"
objRS.Open SQL,objCon
username = objRS("username")
name = objRS("name")
surname = objRS("surname")
email = objRS("email")
age = objRS("age")
country = objRS("country")
gender = objRS("gender")
city = objRS("city")
occupation = objRS("occupation")
homepage = objRS("homepage")
icq = objRS("icq")
visits = objRS("visits")
datum = objRS("date")
lastvisit = objRS("date_time")
--
Martin Johansson,
CEO & Project Supervisor
SD-Studios
+46 (0)70-3003320
http://www.sd-studios.com
|
|
 |