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

Call stored procedure from asp.net

I have an asp.net page (written in vb) and am trying to determine how to call a sql server stored procedure
spCreateBirthdayMailHouseFileASPForm

that has 1 input parameter

@EmailProfileName VARCHAR(1000)

The stored procedure does not return any data but I would like to capture the execution status

Not sure how to format the call

sql connection is in a variable called strConn
0
johnnyg123
Asked:
johnnyg123
1 Solution
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try something like this:

Dim query As String = "spCreateBirthdayMailHouseFileASPForm"
Dim ID As Integer
Dim strConn As String = "<fill out conn string details here>"
Using conn As New SqlConnection(strConn)
  Using cmd As New SqlCommand(query, conn)
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Parameters.AddWithValue("@EmailProfileName", Category.Text)
    cmd.Parameters.Add("@resultStatus", SqlDbType.Int, 0, "CategoryID")
    cmd.Parameters("@resultStatus").Direction = ParameterDirection.Output
    conn.Open()
    cmd.ExecuteNonQuery()
    ID = cmd.Parameters("@resultStatus").Value
  End Using
End Using

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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