[thelist] Freebie ASP/StoredProc Tip

Warden, Matt mwarden at mattwarden.com
Tue Jul 3 10:51:24 CDT 2001


Three headaches later, I figure out what my problem was...

<tip type="Calling MS SQL Server Stored Procedures from ASP">

When calling parameterized stored procedures from ASP, don't try hard. Send
all strings. Not SQL strings. *ASP datatype* strings:

set param = cmd.CreateParameter("param",adVarChar,adParamInput,100,"value")

As opposed to:

set param =
cmd.CreateParameter("param",adVarChar,adParamInput,100,"'value'")

When using numeric type parameters, don't send numeric data. Send string
data:

set param = cmd.CreateParameter("param",adInteger,adParamInput,,"234")

When sending NULL values, send the ASP NULL rather than the string "NULL":

set param = cmd.CreateParameter("param",adVarChar,adParamInput,,NULL)


This one bit me in the ass because I was sending a numeric unique identifier
and never in my wildest dreams would I have thought it needed to be a
string. Obviously, the ADO developers were trying to make it easy on us and
it seems ADO/ODBC takes care of all the database data types. Just happened
to make my life much harder.

</tip>


hth,



--
mattwarden
mattwarden.com






More information about the thelist mailing list