3、 有输出参数,无返回记录集、无返回值
存储过程如下:
CREATE PROCEDURE SP_EXEC_SQL
(
@count int output
)
AS
select @count =count(*)  from zcxx
GO
程序如下:
Dim tempConnection As SqlConnection
        tempConnection = New SqlConnection
        tempConnection.ConnectionString = "server=192.168.0.10;uid=sa;pwd=;database=ZIS_SchoolA"
        tempConnection.Open()
        
        Dim myCmd As New SqlCommand("SP_EXEC_SQL", tempConnection)
        myCmd.CommandType = CommandType.StoredProcedure
        myCmd.Parameters.Add(New SqlParameter("@count", SqlDbType.Int))
        myCmd.Parameters("@count").Direction = ParameterDirection.Output
        myCmd.ExecuteNonQuery()
        
        tempConnection.Close()
        MsgBox(myCmd.Parameters("@count").Value)