如何从 VB.NET 中的存储过程获取返回值 [英] How to get a return value from a stored procedure in VB.NET
本文介绍了如何从 VB.NET 中的存储过程获取返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 SQL Server 中有一个用于生成事务号的存储过程.
I have a stored procedure in SQL Server for generating transaction numbers.
任何人都可以帮助我了解如何从 VB.NET 调用存储过程以及我如何将从过程返回的值获取到前端.
Can anyone help me with how to call the Stored Procedure from VB.NET and how will i get the value that is returned from the procedure into the front end.
问候,乔治
推荐答案
我想你想要这样的:
Public Sub Foo()
Using sql As New SqlClient.SqlConnection("YourConnection")
sql.Open()
Using cmd As New SqlClient.SqlCommand("YourSPName", sql)
cmd.CommandType = CommandType.StoredProcedure
Dim myReturnValue As String = cmd.ExecuteScalar
End Using
End Using
End Sub
其中 myReturnValue 将是您在 SQL 中的输出参数.
Where myReturnValue will be what ever your output param in SQL is.
这篇关于如何从 VB.NET 中的存储过程获取返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文