
VB6->SQL 7 Stored Procedure with Parameters
I am getting the following error is IIS5 "Procedure 'FindCustomer' expects
I have the following stored procedure in SQL Server 7:
AS
SELECT CustomerNumber,Firstname,Surname
FROM Customer
I want to return a RecordSet using the following code VB6 SP4:
I have set up references to the ASP Object library and ADO 2.5
Public Sub FindCustomers()
On Error GoTo ErrorCode
Dim DBConn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim RS As New ADODB.Recordset
Dim prt As New ADODB.Parameter
Dim connStr As String
connStr = "PROVIDER=SQLOLEDB;DRIVER={SQL
Server};SERVER=DAVIDM;DATABASE=CallCentre;UID=callstaff;PWD=lauren;"
PostCode = CStr(ASPrequest.QueryString("PostCode"))
HouseNumber = CStr(ASPrequest.QueryString("HouseNumber"))
Surname = CStr(ASPrequest.QueryString("Surname"))
DBConn.ConnectionString = connStr
DBConn.Open
Set cmd.ActiveConnection = DBConn
cmd.CommandText = "FindCustomer"
cmd.CommandType = adCmdStoredProc
cmd.CommandTimeout = 15
Set prt = cmd.CreateParameter("post", adVarChar, adParamInput, 8)
cmd.Parameters.Append prt
Set prt = cmd.CreateParameter("surn", adVarChar, adParamInput, 15)
cmd.Parameters.Append prt
Set prt = cmd.CreateParameter("house", adVarChar, adParamInput, 6)
cmd.Parameters.Append prt
Set RS = cmd.Execute
If RS.BOF = True And RS.EOF = True Then
Response.Write "CUSTOMER NOT FOUND"
Else
Response.Write RS.Fields("CustomerNumber").Value
Response.Write "<br>"
End If
RS.Close
Set RS = Nothing
DBConn.Close
Set DBConn = Nothing
Exit Sub
ErrorCode:
Response.Write Err.Description
If RS.State = adStateOpen Then
RS.Close
Set RS = Nothing
End If
If DBConn.State = adStateOpen Then
DBConn.Close
Set DBConn = Nothing
End If
End Sub
Any help greatly appreciated,
David Moffat
Glasgow
UK