存储过程的代码
ALTER PROCEDURE dbo.test 
                 @out_aft_nunn                 INT OUTPUT,
                 @out_mObjectNo                INT OUTPUTAS
begin
                                
              set @out_aft_nunn   = 112
                set @out_mObjectNo  =456
end
程序调用的代码        Dim conn As New SqlClient.SqlConnection(Me.ConnectionString)
        Try
            Dim myCmd As New SqlClient.SqlCommand            myCmd.CommandType = CommandType.StoredProcedure
            myCmd.CommandTimeout = 0
            myCmd.CommandText = "dbo.test "
            myCmd.CommandTimeout = 0
            myCmd.Connection = conn
            myCmd.Connection.Open()
            Dim myDap As New SqlClient.SqlDataAdapter(myCmd)            myDap.SelectCommand.Parameters.Add(("@out_aft_nunn"), SqlDbType.Int).Value = 5
            myDap.SelectCommand.Parameters.Add(("@out_mObjectNo"), SqlDbType.Int).Value = 6            myCmd.ExecuteNonQuery()
         
            Dim obj2 As Integer = CInt(myCmd.Parameters(1).Value)
            Dim obj1 As Integer = CInt(myCmd.Parameters("@out_mObjectNo").Value)
            
        Catch ex As Exception
            Throw
        Finally
            conn.Close()
        End Try        'Return "0"
    End Function
以上的代码,调用的存储过程中有多个出参,用.net调用取得的值为什么是我入参的值呢

解决方案 »

  1.   

    .Direction = ParameterDirection.Output
      

  2.   

    myDap.SelectCommand.Parameters.Add(("@out_aft_nunn"), SqlDbType.Int).Value = 5
    myDap.SelectCommand.Parameters.Add(("@out_mObjectNo"), SqlDbType.Int).Value = 6
    输入参数
    你赋值?
      

  3.   

    myDap.SelectCommand.Parameters.Add(("@out_aft_nunn"), SqlDbType.Int).Value = 5
    myDap.SelectCommand.Parameters.Add(("@out_mObjectNo"), SqlDbType.Int).Value = 6
    是赋初期值得,这两个参数在存储过程是出参
      

  4.   

    .Direction = ParameterDirection.Output不知道这句话要什么在身位置啊?
      

  5.   


         Try
                Dim myCmd As New SqlClient.SqlCommand            myCmd.CommandType = CommandType.StoredProcedure
                myCmd.CommandTimeout = 0
                myCmd.CommandText = "dbo.test "
                myCmd.CommandTimeout = 0
                myCmd.Connection = conn
                myCmd.Connection.Open()
                myCmd.Parameters.AddWithValue("@out_aft_nunn", SqlDbType.Int)
                myCmd.Parameters("@out_aft_nunn").Direction = ParameterDirection.Output
                myCmd.Parameters.AddWithValue("@out_mObjectNo", SqlDbType.Int)
                myCmd.Parameters("@out_mObjectNo").Direction = ParameterDirection.Output
                myCmd.ExecuteNonQuery()
                Dim obj2 As Integer = myCmd.Parameters("@out_aft_nunn").Value
            Catch ex As Exception
                Throw
            Finally
                conn.Close()
            End Try
      

  6.   

    不可以
    默认的是输入的
    带output是输出的如果你想指定默认值
    参数就可以直接指定或者多弄几个参数内部转换