如何在 VB.NET 上执行存储过程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16205863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:23:18 来源:igfitidea点击:
How to Execute a Stored Procedure on VB.NET
提问by ivandinglasan
CREATE PROCEDURE DeletetblOfficeEquipmentProfileRecord
@OE_ID varchar(11)
AS
BEGIN
DELETE FROM [EOEMS].[dbo].[tblOfficeEquipmentProfile]
WHERE [OE_ID]=@OE_ID
END
RETURN
GO
Above is my sql stored procedure how will I execute in in vb.net 2003
以上是我的 sql 存储过程,我将如何在 vb.net 2003 中执行
this SP is for delete a records based on an OE_ID chosen on the textbox
此 SP 用于根据文本框中选择的 OE_ID 删除记录
采纳答案by Mandeep Singh
You need the following code for executing a stored procedure
您需要以下代码来执行存储过程
Imports System.Data.SqlClient
Dim conn as New SqlConnection(YourConnectionString)
Dim cmd as SqlCommand = conn.createcommand
conn.open()
cmd.CommandType = CommandType.StoreProcedure
cmd.Parameters.Add(New SqlParameter("@OE", YourValue)
cmd.CommandText = DeletetblOfficeEquipmentProfileRecord
cmd.ExecuteNonQuery()
conn.close()

