Calling a procedure

Discussion in 'ASP .Net' started by Jon Cosby, Aug 11, 2003.

  1. Jon Cosby

    Jon Cosby Guest

    How do you call an existing procedure? My database has a procedure called
    "StudentSchedule" with one parameter, @StudentID. I'm trying to fill the
    results in a datagrid with a StoredProcedure command. The grid is not even
    showing on the page.

    SqlCommand cmdSchedule = new SqlCommand("StudentSchedule", this.cnBCC);
    cmdSchedule.CommandType = CommandType.StoredProcedure;

    SqlParameter studID = cmdSchedule.Parameters.Add("@StudentID",
    SqlDbType.NChar, 9);
    studID.Value = this.tbSID.Text.Trim();

    SqlDataAdapter daSchedule = new SqlDataAdapter(cmdSchedule);
    DataSet ds = new DataSet();

    daSchedule.Fill(ds);
    this.dgStudents.DataSource = ds;


    Jon Cosby
     
    Jon Cosby, Aug 11, 2003
    #1
    1. Advertising

  2. Add this line at the end:

    this.dgStudents.DataBind();

    --
    James J. Foster, DotNetCoders
    http://www.dotnetcoders.com


    "Jon Cosby" <> wrote in message
    news:bh8f1d$kf$...
    > How do you call an existing procedure? My database has a procedure called
    > "StudentSchedule" with one parameter, @StudentID. I'm trying to fill the
    > results in a datagrid with a StoredProcedure command. The grid is not even
    > showing on the page.
    >
    > SqlCommand cmdSchedule = new SqlCommand("StudentSchedule",

    this.cnBCC);
    > cmdSchedule.CommandType = CommandType.StoredProcedure;
    >
    > SqlParameter studID = cmdSchedule.Parameters.Add("@StudentID",
    > SqlDbType.NChar, 9);
    > studID.Value = this.tbSID.Text.Trim();
    >
    > SqlDataAdapter daSchedule = new SqlDataAdapter(cmdSchedule);
    > DataSet ds = new DataSet();
    >
    > daSchedule.Fill(ds);
    > this.dgStudents.DataSource = ds;
    >
    >
    > Jon Cosby
    >
    >
     
    James J. Foster, Aug 11, 2003
    #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. JN
    Replies:
    0
    Views:
    3,224
  2. Sudhish K V

    Calling Oracle stored procedure using c#

    Sudhish K V, Nov 11, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    6,964
    David Browne
    Nov 11, 2003
  3. Paul
    Replies:
    1
    Views:
    383
    =?Utf-8?B?UmFtaXJvIENhbGRlcm9u?=
    Jan 19, 2004
  4. Mike P
    Replies:
    0
    Views:
    3,334
    Mike P
    Jun 19, 2006
  5. AlexWare
    Replies:
    2
    Views:
    776
    Paul Uiterlinden
    Oct 23, 2009
Loading...

Share This Page