Click to See Complete Forum and Search --> : ASP & VBScript Question...


kwilliams
03-29-2004, 12:26 PM
I have this code:
<%
strID = Session("Agenda_ID")
'Response.Write(strID) 'TEST'S PULLING OF ID
strDelete = Session("DeletePacket")
strRedirect = "/FOLDER/SUBFOLDER/agendas_thankyou.asp"
%>
<%
if strDelete = "N" then
Response.Redirect(strRedirect)
End if
%>
<%
'UPDATE PACKET
if strDelete = "Y" then
Set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_strConn_Login_STRING
Command1.CommandText = "UPDATE dbo.Commission_Agendas SET Packet = NULL WHERE Agenda_ID = 'strID'"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
Set Command1 = nothing
%>
...but I get this error message:
Microsoft OLE DB Provider for SQL Server error '80040e07'

Syntax error converting the varchar value '%strID%' to a column of data type int.

/ScriptLibrary/fsoDeleteFile.asp, line 30

Line 30 is referencing the UPDATE statement. Does anyone see why it won't use "strID" as a filter? strID is the ID for the table, and it's datatype is int. This works find in JavaScript, but the VBScript version is giving me this weird message. ANy & all help is appreciated. Thanks.

buntine
03-29-2004, 12:34 PM
ASP doesnt know that strId is a variable. Use the following SQL query.

"UPDATE dbo.Commission_Agendas SET Packet = NULL WHERE Agenda_ID = " & strID

Also, you dont need quotes around an integer value. If strID contains characters, then use the following SQL query:

"UPDATE dbo.Commission_Agendas SET Packet = NULL WHERE Agenda_ID = '" & strID & "'"


Regards.

kwilliams
03-29-2004, 12:39 PM
buntine,

And these are the little things we learn when changing to VBScript. Thanks for the quick response...it worked great!

buntine
03-29-2004, 12:40 PM
No worries;)

Glad to help you out.