using sqldatasource with few queries

Discussion in 'ASP .Net' started by ruthiefy@walla.co.il, Feb 11, 2007.

  1. Guest

    Hi,

    Is it possible to use the sqldatasource when I need a few
    Select Commands on the same page?
    I notice that I can put only one Select Command?
    What is the recommanded approach in my case?

    Thanks.
    Ruthie.
    , Feb 11, 2007
    #1
    1. Advertising

  2. Better use separate sqldatasources. The whole idea of sqldatasource is to
    make your data access as simple as possible. It is not good for anything
    above primitive and trivial.

    In many cases all you need is just to read some data with a single select
    statement to populate a control. For this situation you will want to use a
    light read-only access that is provided by datareader controls. You can use
    a sqldatasource and set its DataSourceMode property to datareader. If you
    want to be a bit more in control, use just an SqlCommand object and run
    queries with the ExecuteReader method. The method returns a datareader that
    you can databind to a control via the DataSource property.


    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    <> wrote in message
    news:...
    > Hi,
    >
    > Is it possible to use the sqldatasource when I need a few
    > Select Commands on the same page?
    > I notice that I can put only one Select Command?
    > What is the recommanded approach in my case?
    >
    > Thanks.
    > Ruthie.
    >
    Eliyahu Goldin, Feb 11, 2007
    #2
    1. Advertising

  3. Guest

    On Feb 11, 5:24 pm, "Eliyahu Goldin"
    <> wrote:
    > Better use separate sqldatasources. The whole idea of sqldatasource is to
    > make your data access as simple as possible. It is not good for anything
    > above primitive and trivial.
    >
    > In many cases all you need is just to read some data with a single select
    > statement to populate a control. For this situation you will want to use a
    > light read-only access that is provided by datareader controls. You can use
    > a sqldatasource and set its DataSourceMode property to datareader. If you
    > want to be a bit more in control, use just an SqlCommand object and run
    > queries with the ExecuteReader method. The method returns a datareader that
    > you can databind to a control via the DataSource property.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
    >
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi,

    >
    > > Is it possible to use the sqldatasource when I need a few
    > > Select Commands on the same page?
    > > I notice that I can put only one Select Command?
    > > What is the recommanded approach in my case?

    >
    > > Thanks.
    > > Ruthie.- Hide quoted text -

    >
    > - Show quoted text -


    Thanks Eliyahu.

    Your answer really helps!!!
    , Feb 12, 2007
    #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. Dirk Vervecken

    Using Access queries via asp.net

    Dirk Vervecken, Jun 3, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    508
    Dirk Vervecken
    Jun 4, 2004
  2. Ian Roddis

    xslt queries in xml to SQL queries

    Ian Roddis, Feb 26, 2006, in forum: Python
    Replies:
    3
    Views:
    1,475
    Crutcher
    Feb 26, 2006
  3. Murali
    Replies:
    2
    Views:
    545
    Jerry Coffin
    Mar 9, 2006
  4. Abby Lee

    so many queries within queries I'm confused

    Abby Lee, Aug 4, 2004, in forum: ASP General
    Replies:
    11
    Views:
    341
    Aaron [SQL Server MVP]
    Aug 6, 2004
  5. Sneha Bendre

    Few queries about Ruby implementation

    Sneha Bendre, May 29, 2007, in forum: Ruby
    Replies:
    0
    Views:
    99
    Sneha Bendre
    May 29, 2007
Loading...

Share This Page