How to Execute a Stored Procedure on VB.NET
sql, stored-procedures, vb.net
Solution
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()
Problem
``` 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 this SP is for delete a records based on an OE_ID chosen on the textbox