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)
存储过程如下:
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)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货