Execute Stored Procedure from VB
This seems like such a simple thing I can not believe how much trouble I am having finding a sample. All I want to do is run a StroredProcedure in my VB.Net app. Can someone point me to a sample.
Everything I have found is returning results. All I want to do is run the procedure.
Re: Execute Stored Procedure from VB
In waht database? Just run the prodcure and don't set the return to anything?
Re: Execute Stored Procedure from VB
Sounds like this example will be what you need. Just dont use the parameter as you dont need t retunr anything.
http://samples.gotdotnet.com/quickst...OutParams.aspx
Re: Execute Stored Procedure from VB
This is what if ended up with and it seems to work fine. However I am wondering if there is something that I can add that will tell me the procedure finished the task?
Code:
Dim cn As SqlConnection = New SqlConnection
cn.ConnectionString = Con
cn.Open()
Dim cmd As SqlCommand = New SqlCommand("sp_InsertInv", cn)
cmd.CommandType = CommandType.StoredProcedure
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & _
ex.Source, "Data Error", MessageBoxButtons.OK)
End Try
Re: Execute Stored Procedure from VB
if you don't get the error message box... then it ran..
-tg
Re: Execute Stored Procedure from VB
If you wanted to get fancy, you could modify your sp to return the number of records affected.