• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 848
  • Last Modified:

Call an Insert SQL Stored Procedure from VB

I have a stored procedure that is an INSERT INTO  statement and returns no rows.  

As far as calling the Procedure -  Here is what I have so far..... How do i execute the rest?

Do I need to alter the Stored Procedure to return a success/failure variable?

Dim StrCon As String = "My Connection Info"
        Dim connection As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(StrCon)
        Dim xUserID As Integer
        Dim command As New Data.SqlClient.SqlCommand
        Command.Connection = connection
        Command.CommandType = Data.CommandType.StoredProcedure
        command.CommandText = "NewData"
        command.Parameters.AddWithValue("@ID", xUserID)

Open in new window

  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
next line would be

Open in new window

rrowe68Author Commented:
Thanks AngelIII is there any variable to notice if successful or not?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if there is an sql error raised, it failed.
otherwise, the sql completed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now