urgent asp.net Help:

Discussion in 'ASP .Net' started by =?Utf-8?B?YW1qYWQ=?=, Jun 8, 2006.

  1. i am posting below code i am not sure how to call parametrized store
    procedure and fill the grid.
    ....
    I have store procedure which pull the info from sql server 2005 using
    asp.net 1.1... that proc accept two parameters .
    any body has any idea how to do that thing using dataset ....
    thanks
    public DataSet GetCustByDate(int MonthNo,string YearNo)
    {
    strSQL="dbo.sp_GetCust " + MonthNo.ToString() + " , " + YearNo;

    SqlConnection conn = this.GetConnection();
    conn.Open();
    SqlDataAdapter myCommand = new SqlDataAdapter(strSQL, conn);
    DataSet ds = new DataSet();
    myCommand.Fill(ds, strSQL);
    conn.Close();

    return ds;

    }
    =?Utf-8?B?YW1qYWQ=?=, Jun 8, 2006
    #1
    1. Advertising

  2. Amjad,
    This is the WRONG way to use ADO.NET to make a stored procedure call!
    You are using the Language path through SQL Server, and you want to use the
    RPC path instead.

    1) Create a SqlCommand object, set it's CommandText property to the name of
    the stored proc, and it's CommandType property to StoredProcedure.
    2) Create a SqlParameter object for each named parameter, assign it the
    actual parameter value, and add the Parameter to the SqlCommand's Parameters
    collection.

    3) Assign the Command to the SelectCommand property of the DataAdapter and
    continue as you did before.

    --Peter
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "amjad" wrote:

    > i am posting below code i am not sure how to call parametrized store
    > procedure and fill the grid.
    > ...
    > I have store procedure which pull the info from sql server 2005 using
    > asp.net 1.1... that proc accept two parameters .
    > any body has any idea how to do that thing using dataset ....
    > thanks
    > public DataSet GetCustByDate(int MonthNo,string YearNo)
    > {
    > strSQL="dbo.sp_GetCust " + MonthNo.ToString() + " , " + YearNo;
    >
    > SqlConnection conn = this.GetConnection();
    > conn.Open();
    > SqlDataAdapter myCommand = new SqlDataAdapter(strSQL, conn);
    > DataSet ds = new DataSet();
    > myCommand.Fill(ds, strSQL);
    > conn.Close();
    >
    > return ds;
    >
    > }
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jun 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. peter
    Replies:
    2
    Views:
    355
    Curt_C [MVP]
    Aug 31, 2004
  2. John
    Replies:
    0
    Views:
    506
  3. Sachin Jagtap

    URGENT !! QUEUE STL PROBLEM URGENT!!

    Sachin Jagtap, Apr 28, 2005, in forum: C++
    Replies:
    4
    Views:
    1,031
    Mark Stijnman
    Apr 29, 2005
  4. Rob
    Replies:
    3
    Views:
    427
  5. Replies:
    1
    Views:
    253
Loading...

Share This Page