在asp.net中如何获得SQL存储过程传回的多个输出参数(output)值?

解决方案 »

  1.   

    Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
                                                          "Initial Catalog=northwind")Dim catDA As SqlDataAdapter = New SqlDataAdapter("SELECT CategoryID, CategoryName FROM Categories", nwindConn)catDA.InsertCommand = New SqlCommand("InsertCategory" , nwindConn)
    catDA.InsertCommand.CommandType = CommandType.StoredProcedureDim myParm As SqlParameter = catDA.InsertCommand.Parameters.Add("@RowCount", SqlDbType.Int)
    myParm.Direction = ParameterDirection.ReturnValuecatDA.InsertCommand.Parameters.Add("@CategoryName", SqlDbType.NChar, 15, "CategoryName")myParm = catDA.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "CategoryID")
    myParm.Direction = ParameterDirection.OutputDim catDS As DataSet = New DataSet()
    catDA.Fill(catDS, "Categories")Dim newRow As DataRow = catDS.Tables("Categories").NewRow()
    newRow("CategoryName") = "New Category"
    catDS.Tables("Categories").Rows.Add(newRow)catDA.Update(catDS, "Categories")Dim rowCount As Int32 = CInt(catDA.InsertCommand.Parameters("@RowCount").Value)