Data Type Mismatch

Data Type Mismatch

am 24.02.2007 20:23:33 von mwagoner

can anyone help with why this is returning a Data Type mismatch error?

dim strTestDate, strJobNumber

strTestDate = "3/8/2007"
strJobNumber = Request.QueryString("JobNumber")


strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=\
\CALSJ1\PMAPPS\Intranet\pmdata.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
strSQL = "SELECT * FROM tblWJS_SuperInput WHERE JobNumber = '"&
strJobNumber &"' AND WeekEndingDate = '"& strTestDate &"' "


conn.Open strConnect
Set objRecordSet = conn.Execute(strSQL)

Re: Data Type Mismatch

am 24.02.2007 20:41:45 von reb01501

Matt wrote:
> can anyone help with why this is returning a Data Type mismatch error?
>
> dim strTestDate, strJobNumber
>
> strTestDate = "3/8/2007"
> strJobNumber = Request.QueryString("JobNumber")
>
>
> strConnect = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=\
> \CALSJ1\PMAPPS\Intranet\pmdata.mdb"

Nothing to do with your problem, but:
http://www.aspfaq.com/show.asp?id=2126

> Set conn = Server.CreateObject("ADODB.Connection")
> strSQL = "SELECT * FROM tblWJS_SuperInput WHERE JobNumber = '"&
> strJobNumber &"' AND WeekEndingDate = '"& strTestDate &"' "
>
Date literals need to be delimited with octamorphs (#) when composing
dynamic sql strings, not quotes. Quotes are used for strings only.

Further points to consider:
Your use of dynamic sql is leaving you vulnerable to hackers using sql
injection:
http://mvp.unixwiz.net/techtips/sql-injection.html
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23

See here for a better, more secure way to execute your queries by using
parameter markers:
http://groups-beta.google.com/group/microsoft.public.inetser ver.asp.db/msg/72e36562fee7804e

Personally, I prefer using stored procedures, or saved parameter queries
as
they are known in Access:

Access:
http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&sel m=e6lLVvOcDHA.1204%40TK2MSFTNGP12.phx.gbl

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1& selm=eHYxOyvaDHA.4020%40tk2msftngp13.phx.gbl



--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"