VB6使用参数调用存储过程

时间:2011-05-26 09:19:32

标签: stored-procedures vb6

正如头条说我想用参数调用存储过程。 下面是VB6功能

Private Sub TestProcedur()     Dim strSql As String     Dim CPw as rdoQuery

strSql$ = "? = {call Insert_Student(?) }"
Set CPw = gRdoConn.CreateQuery("InsertStudent", strSql)

CPw.rdoParameters(0).Direction = rdParamReturnValue



CPw(1) = "FRANK"

Set mrsR = CPw.OpenResultset()

End Sub

下面的存储过程

CREATE PROCEDURE Insert_Student
    @Name VARCHAR(50)
AS
BEGIN
    INSERT INTO dbo.Student (Name)
    VALUES (@Name)
END
GO

运行该功能时出现问题。运行“CPw.rdoParameters(0).Direction = rdParamReturnValue”行时出现错误消息:“无效描述索引”

1 个答案:

答案 0 :(得分:1)

MSDN上的这个页面应该很好地解释它:

http://msdn.microsoft.com/en-us/library/aa240826%28v=VS.60%29.aspx