In a stored procedure, @ID is a parameter, not plain text
that gets added to
your query. Of course copy/pasting the list into QA would
work because that
IS plain text getting added to the query. If you'd defined a
parameter in
QA, it would also have failed.
DECLARE @ID INT
SET @ID = '1, 2, 3, 4' --this will fail
You can write the update for a single ID, then execute in a
loop
Set up your command object
For Each ID in IDList
Command.Parameters("@ID").Value = ID
Command.Execute ,,128
Next
Or you could use one of the array/list techniques here:
http://www.sommarskog.se/arrays-in-sql.html
"SIMON" <simon@home.com> wrote in message
news:ef301q$8il$1@forums.macromedia.com...
>I have an asp page that passes between 1 and 20 ID's in a
string to another
>asp page where an Update is triggered. The string looks
like:
> 10023567, 1000345, 90885543211
> or it could be just one ID like:
> 27736458
>
> My update stored procedure is:
>
> Update Bookings
> SET Status = 'Accepted'
> WHERE BookingID IN (@ID)
>
> @ID is the string mentioned above. If there is only 1 ID
in the string
> then the Update is performed but if there is more than 1
ID I get "cannot
> convert Varchar to Int" error.
>
> If I take the string contents and use them in Query
Analyser eg.
>
> Update Bookings
> SET Status = 'Accepted'
> WHERE BookingID IN (10023567, 1000345, 90885543211)
>
> it works fine and updates the correct rows, so why do I
get the error when
> attempting it in an asp page?
>