3
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

Mark Davidson
  • 5,503
  • 5
  • 35
  • 54
ivandinglasan
  • 384
  • 4
  • 15
  • 29

1 Answers1

4

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()
andy
  • 5,979
  • 2
  • 27
  • 49
Mandeep Singh
  • 2,016
  • 7
  • 19
  • 32
  • cmd.Parameters.Add(New SqlParameter("@OE_ID", NVarChar.NVarChar)) error sir, Run-time exception thrown : System.Data.SqlClient.SqlException - Procedure 'DeletetblOfficeEquipmentProfileRecord' expects parameter '@OE_ID', which was not supplied. – ivandinglasan Apr 26 '13 at 00:54
  • try with this Dim OE_ID as string = "10" cmd.Parameters.Add(New SqlParameter("@OE_ID", OE_ID)) – Mandeep Singh Apr 26 '13 at 05:03