Call stored procedure in ASP.NET 2.0 - Inetserver

This is a discussion on Call stored procedure in ASP.NET 2.0 - Inetserver ; 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'. ...

+ Reply to Thread
Results 1 to 3 of 3

Call stored procedure in ASP.NET 2.0

  1. Default Call stored procedure in ASP.NET 2.0

    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



  2. Default Re: Call stored procedure in ASP.NET 2.0

    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
    >




  3. Default Re: Call stored procedure in ASP.NET 2.0

    "syoung" <saleyoun@hotmail.com> wrote in message
    news:8bSdnWpx4KYpD6jeRVn-qg@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...? ;-)



+ Reply to Thread

Similar Threads

  1. Trying to call a stored procedure from C# (and failing)
    By Application Development in forum ADO DAO RDO RDS
    Replies: 8
    Last Post: 08-26-2007, 04:08 PM
  2. Stored Procedure Call using EJB 3.0
    By Application Development in forum Java
    Replies: 0
    Last Post: 11-22-2006, 09:05 AM
  3. Stored Procedure call using MSSQL::DBLIB
    By Application Development in forum Perl
    Replies: 0
    Last Post: 04-06-2006, 04:07 PM
  4. Replies: 0
    Last Post: 10-14-2005, 09:53 AM
  5. Best way to call a stored procedure
    By Application Development in forum basic.visual
    Replies: 1
    Last Post: 06-18-2004, 03:05 PM