I have to call a stored procedure in a SQL Server database from classic asp (VBScript)
The problem is that one of the parameters of the stored procedure is of type "binary(1)". I have looked at the VBscript data type constants for ADO and it seems that the equivalence for SQL binary types is AdBinary, but I don't know how to deal with this kind of data type from classic ASP. I have tried to set the value but I get wrong type errors. Is it possible in classic ASP to convert a numeric or a string value to binary data?
Invoking the same procedure using a query string like "Exec Procedure..." seems to work just concatenating the value for the binary parameter, but I have no idea of how to do the same using the ADODB.Command object.
Maybe someone have faced this situation before?
Dim bvalue
Dim Conn
Dim objCommand
Dim RS
Set Conn = CreateObject("ADODB.Connection")
Conn.Open CONNECTION_STRING
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = Conn
objCommand.CommandText = "GetBinaryId"
objCommand.CommandType = adCmdStoredProc
objCommand.NamedParameters = True
bvalue = 15
objCommand.Parameters.Append objCommand.CreateParameter("@Id",adBinary,adParamInput,1,bvalue)
set RS = objCommand.Execute
.Value
property using the.CreateParameter()
method,.Value
is set by the 5th argument. – user692942Int
and it's expectingBinary
data. It would be easier to pass the value as anadinteger
in your Stored Procedure` and just useCONVERT(VARBINARY(MAX), @Id)
. Save yourself a lot of grief trying to convert to Binary using VBScript. – user692942