|
-
May 17th, 2001, 08:39 AM
#1
ADO: Call Stored Procedure with out-parameters
Hi,
i have a stored procedure which i declared this way:
CREATE PROCEDURE dbo.sp_anzRomaneProAutor @name text, @anz int output AS
SELECT @anz= count(*)
FROM Roman INNER JOIN
Mitarbeiter ON Roman.Autor = Mitarbeiter.ID
WHERE (Mitarbeiter.Name LIKE @name)
GO
Now i wrote a little basic-application to call this procedure:
set rsPRAutor = cmPR.Execute
set pmPRAutorName = cmPR.CreateParameter("@Name", adBSTR, adParamInput)
cmPR.Parameters.Append pmPRAutorName
set pmPRAutorAnz = cmPR.CreateParameter("@anz", adInteger, adParamOutput)
cmPR.Parameters.Append pmPRAutorAnz
rsPRAutor.MoveFirst
While (Not rsPRAutor.EOF)
'Anzahl der Romane pro Autor lesen
cmPR.CommandText = "sp_anzRomaneProAutor"
cmPR.CommandType = adCmdStoredProc
pmPRAutorName.Value = rsPRAutor.Fields(0)
set rsPRAnz = cmPR.Execute
rsPRAutor.MoveNext
Wend
but if i watch thr pmPrAutorAnz and the rsPRAnz-Object there a no values field in. The count of fields of rsPRAnz is 0 and pmPrAutorAnz is also 0.
What have i done wrong? How can i call a stored procedure within VB and receive the result of the procedure?
Thanks
akademos
-
May 17th, 2001, 01:37 PM
#2
Re: ADO: Call Stored Procedure with out-parameters
Dim con as new adodb.connection
dim rst as new adodb.recordset
con.Open "Driver{SQLServer};Server=servername;Uid=userID;Pwd=password;Database=DBName"
set rst = con.execute("sp_anzRomaneProAutor " & "'" & name_text & "'"
if (rst.eof = false or rst.bof = false) then
do
'what ever you want to do with the record
rst.movenext
loop until rst.eof = true
end if
Rate it, if Helps
-
May 18th, 2001, 01:46 AM
#3
Re: ADO: Call Stored Procedure with out-parameters
This doesn't work also:
1. I have a second parameter which is a out-parameter
2. In my original code it tells me that my recordset isn't opened so i can't use funktions such as .EOF, .MoveNext or similar
thanks
akademos
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|