Using a DataReader in VS NET

Discussion in 'ASP .Net' started by Wayne Wengert, Jan 22, 2004.

  1. I am trying to learn to use VS NET and codebehind for asp.net apps and I've
    run into a problem trying to use a datareader.

    I created a new webform and inserted and configured a sqlconnection and I
    inserted a sqlcommand object with the query string. The form has a datagrid
    object which I want to bind to the returned data. I want to add a datareader
    to get the actual data but I cannot find a datareader in the toolbox? I
    looked under the data tab and several others.

    I previously coded all this in an in-line code format and it works. How do I
    do this (correctly) in VS NET 2003?

    I suspect I am going at this the wrong way. Any advice or pointers are
    appreciated
     
    Wayne Wengert, Jan 22, 2004
    #1
    1. Advertising

  2. I think I found my main confusion. In searching various web sites I found
    that SQLCommand exposes an ExecuteReader method which creates the reader.

    To use this, do I just write the code in the codebehind module to execute
    that method or is there some procedure in the IDE I am supposed to use?

    Wayne
    "Wayne Wengert" <> wrote in message
    news:...
    > I am trying to learn to use VS NET and codebehind for asp.net apps and

    I've
    > run into a problem trying to use a datareader.
    >
    > I created a new webform and inserted and configured a sqlconnection and I
    > inserted a sqlcommand object with the query string. The form has a

    datagrid
    > object which I want to bind to the returned data. I want to add a

    datareader
    > to get the actual data but I cannot find a datareader in the toolbox? I
    > looked under the data tab and several others.
    >
    > I previously coded all this in an in-line code format and it works. How do

    I
    > do this (correctly) in VS NET 2003?
    >
    > I suspect I am going at this the wrong way. Any advice or pointers are
    > appreciated
    >
    >
     
    Wayne Wengert, Jan 22, 2004
    #2
    1. Advertising

  3. Wayne  Wengert

    Cor Guest

    Hi Wayne,

    Working with a datagrid is working with a table (basedatalist)

    It is very complicated, but doing it for one database table very easy

    I write some code in vb.net (C# is almost the same) and with SQL when it it
    OleDB change SQL for OleDB
    All here written in the message so watch typos
    \\\
    Dim conn as new SQLconnection(your connectionstring)
    dim ds as new dataset
    dim da as new SQLdataadapter("myselectstring", conn)
    da.fill(ds)
    datagrid1.datasource=ds.tables(0)
    datagrid1.databind
    ///
    Ready the datagrid with your table will be showed.
    (For C# you have to watch the cases also)


    I hope this helps?

    Cor

    "> I am trying to learn to use VS NET and codebehind for asp.net apps and
    I've
    > run into a problem trying to use a datareader.
    >
    > I created a new webform and inserted and configured a sqlconnection and I
    > inserted a sqlcommand object with the query string. The form has a

    datagrid
    > object which I want to bind to the returned data. I want to add a

    datareader
    > to get the actual data but I cannot find a datareader in the toolbox? I
    > looked under the data tab and several others.
    >
    > I previously coded all this in an in-line code format and it works. How do

    I
    > do this (correctly) in VS NET 2003?
    >
    > I suspect I am going at this the wrong way. Any advice or pointers are
    > appreciated
    >
    >
     
    Cor, Jan 22, 2004
    #3
    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. Replies:
    1
    Views:
    1,580
  2. Replies:
    0
    Views:
    453
  3. Replies:
    0
    Views:
    437
  4. Randall

    Using two Datareader

    Randall, Oct 28, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    1,748
    Randall
    Oct 29, 2003
  5. Andrei Pociu
    Replies:
    4
    Views:
    520
    Andrei Pociu
    Oct 14, 2004
Loading...

Share This Page