存储过程上不需要Input或Output的,定义了游标也没有用,在存储过程中,你只要执行Selete语句就可以了。在VB中用recordset直接接收就可以了。
只是你在这时候不能对SQL的这个存储进行调试了。

解决方案 »

  1.   

    如楼上如说可以做到。
    如果你用的是SQL2000,干脆使用自定义FUNCTION,它可以返回表。
      

  2.   

    但是我的存储过程中必须要有条件input,
      

  3.   

    创建存储过程
    Create Procedure ResultValue(@a char(5),@b char(5),@c char(5)) As
    set nocount no 
    create table #t1 (f1 char(5),f2 char(5),f3 char(5))
    insert #t1(f1,f2) select ta.f1,tb.f2,tc.f3 from ta,tb,tc where 
     ta.a=@a and tb.b=@b and tc.c=@c
    select f1,f2 from #t1
    drop table #t1
    set nocount off
    returnVB中调用
    dim cnn as New ADODB.Connection
    dim cmd as New ADODB.Command
    dim rst as New ADODB.Recordset..............
    cmd.CommandText="{?=Call dbo.ResultValue(?,?,?)}"
    cmd.CommandType = adCmdText
    cmd.Parameters.Refresh
    cmd.Parameters(0).Value="1234"
    cmd.Parameters(1).Value="23456"
    cmd.Parameters(2).Value="34565"
    set rst=cmd.Execute
    set datagrid1.DataSource=rst
    datagrid1.ReBind 
    .........