Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

execute a delete stored procedure?

Status
Not open for further replies.

RMasters

Programmer
Nov 14, 2000
36
0
0
GB
I am trying to execute a stored procedure that requires an input parameter, the purpose of the procedure is to delete a record in a table (based on the ID that I pass it)
I cannot find an example of this anywhere.

The stored procedure works fine, my problem is running it from code.

I would really appreciate some help.
 
Dim oConn as System.Data.SqlClient.SqlConnection()
Dim oCMD as System.Data.SqlClient.SqlCommand()

'set your conn string and establish a sql connection

With oCmd
.Connection = oConn
.CommandText = "APP_DeleteUser"
.CommandType = CommandType.StoredProcedure.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = yourId
.ExecuteNonQuery()

End With
 
One more thing.

Set Command to nothing:
If Not IsNothing(oCmd) Then oCmd = Nothing

Close db connection:
oConn.Close

Set Connection to nothing:
If Not IsNothing(oConn) Then oConn= Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top