
ASP, SQL Server 6.5, VBScript, HELP!!!
Hello everyone,
I'm having a real problem with a "simple" VBScript. I want to execute a
stored procedure that takes a parameter. I'm learning ADO and VBScript
(coming from Java land) and I would like to execute "sp_spaceused authors"
on the pubs database on SQL Server 6.5. When I run SQL Trace, I connect to
the database, pass the stored procedure, and execute it. The problem is
that the parameter, in this case "authors", is not being appended to the
stored procedure. Essentially, all that is executed is "sp_spaceused". My
question is, what the heck am I doing wrong? My code is below. I apologize
if this post is inappropriate for this newsgroup, I'm new.
Thanks,
Damon Torgerson
Oh yeah, I'm using IIS 4.0 if that matters.
odbc_driver = "DRIVER={SQL Server};SERVER=DAMONT_SRV;UID=sa;APP=Microsoft(R)
Windows NT(TM) Operating _
System;WSID=DAMONT_SRV;LANGUAGE=us_english;DATABASE=pubs"
' establish connection to the database
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open odbc_driver,"sa",""
' set up the stored procedure
Set banCardCommand=Server.CreateObject("ADODB.Command")
Set banCardCommand.ActiveConnection=Conn
banCardCommand.CommandType=adCMDStoredProc
banCardCommand.CommandText="sp_spaceused"
' set up the parameter to be passed to the stored procedure
txCCNum = "authors"
Set prm=banCardCommand.CreateParameter("Test", adVarChar, adParamInput, 92,
txCCNum)
banCardCommand.Parameters.Append prm
Set prm=nothing
' execute stored procedure
Set RS = CreateObject("ADODB.RecordSet")
Set RS = banCardCommand.Execute()
while not RS.EOF
Response.Write(RS("rows"))
Response.Write("Hello")
RS.MoveNext
wend
' close connections
banCardCommand.Close
Conn.Close