views:

170

answers:

2

Hey everyone,

I've never developed in ASP in my life, but a client wants some additional functionality in one of his really terrible ASP programs extended. I've tried to pick up as much as I can in a short period of time, but I'm running into a mystery bug here.

When I unit-test this code on my local system, it works fine. On their webserver, however, when executing the below code, I get a type mismatch on the line "Item_IDs = ..."

Any suggestions?

Thanks! -Drew

Item_IDs = RetrieveSerialItem_IDs(Serial_IDs(y))

function RetrieveSerialItem_IDs(Serial_ID)

    '' # Execute query and return data in an array
    strQuery = "SELECT Item_ID FROM Store_Items_Serials WHERE Serial_ID = " & Serial_ID & ";"
    RetrieveSerialItem_IDs = RunSelectQuery(strQuery, "Item_ID")

end function '' # RetrieveSerialItem_IDs

'' # Function to execute a SELECT query from our database
'' # returns: the results of the query as a one-dimensional array -- do not use for multiple-column select statements
function RunSelectQuery(strSelectQuery, strColumnName)
+1  A: 

In my book, 90% of the time, this kind of error are because the sql is bad.

Other problem that I see, is that you are not declaring your variables (maybe it is required in the server and not in your dev machine)

How to debug in ASP classic:

Item_IDs = RetrieveSerialItem_IDs(Serial_IDs(y))

function RetrieveSerialItem_IDs(Serial_ID)

    ''//Please, declare your variables
    dim strQuery

    ''//Execute query and return data in an array
    strQuery = "SELECT Item_ID FROM Store_Items_Serials WHERE Serial_ID = "
    strQuery = strQuery  & Serial_ID & ";"

    response.write strQuery
    response.end

    ''// Now, paste the StrQuery text obtained in your sql console and test it


    RetrieveSerialItem_IDs = RunSelectQuery(strQuery, "Item_ID")

end function
Eduardo Molteni
Ah, the not declaring my variables was a holdover from PHP. I will do this from now on.
ModeEngage
A: 

If the same query string variable get's used more than once classic ASP treats it as a comma separated list.

So a URL of foobar.asp?id=1&id=2&id=3 means the id variables ends up as "1,2,3" - a string, not an array.

dantefs