By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

Call stored procedure in ASP.NET 2.0

P: n/a
I would like to know if anyone knows how to execute a stored procedure from
ASP.NET 2.0. I'm using the NorthWind database and I'm trying to execute the
"CustOrderHist" stored procedure. The error I get is "Incorrect syntax
near 'CustOrderHist'. "
Public Function GetCustomerOrderHistory(ByVal customerid As String) As
SqlDataReader
Dim conn As New SqlConnection(conString)
Dim cmd As New SqlCommand("CustOrderHist", conn)
cmd.Parameters.AddWithValue("@CustomerID", customerid)
conn.Open()
Dim dtr As SqlDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return dtr
End Function
Sep 24 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Just found my answer in the post from Mark Rae. I was missing the value for
the CommandType.

Thanks!

Public Function GetCustomerOrderHistory(ByVal customerid As String) As
SqlDataReader
Dim conn As New SqlConnection(conString)
Dim cmd As New SqlCommand("CustOrderHist", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@CustomerID", customerid)
conn.Open()
Dim dtr As SqlDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return dtr
End Function
I would like to know if anyone knows how to execute a stored procedure from
ASP.NET 2.0. I'm using the NorthWind database and I'm trying to execute
the "CustOrderHist" stored procedure. The error I get is "Incorrect
syntax near 'CustOrderHist'. "
Public Function GetCustomerOrderHistory(ByVal customerid As String) As
SqlDataReader
Dim conn As New SqlConnection(conString)
Dim cmd As New SqlCommand("CustOrderHist", conn)
cmd.Parameters.AddWithValue("@CustomerID", customerid)
conn.Open()
Dim dtr As SqlDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
Return dtr
End Function

Sep 24 '05 #2

P: n/a
"syoung" <sa******@hotmail.com> wrote in message
news:8b********************@comcast.com...
Just found my answer in the post from Mark Rae. I was missing the value
for the CommandType.


:-)

Now, any chance you can fix my problem...? ;-)
Sep 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.