one sql call - multiple labels populated?

Discussion in 'ASP .Net Web Controls' started by karlid, Sep 24, 2003.

  1. karlid

    karlid Guest

    hello,

    I'm moving from the old ASP paradigm over to the new ASP.NET paradigm.
    So far so good but I'm stumped on something that seems like it should
    be really easy.

    In the old days you would use a single Record Set to populate a bunch
    of controls all at the same time. For example, when a page loads it
    reads from the database and populates a bunch of controls on a web
    form.

    My question is: How do I do this in ASP.NET?

    I can't seem to figure out how to make a single call to the DB and
    grab a single Row and then populate a bunch of labels based on the
    results.

    Does anyone know of any good references or have any source that I can
    see? I am using VB.NET.

    Thanks for your help in advance.
     
    karlid, Sep 24, 2003
    #1
    1. Advertising

  2. karlid

    Alvin Bruney Guest

    the model has changed. you get a dataset and store the data in there. when
    you want to populate, you bind to the dataset. this keeps the load off of
    the datasource
    "karlid" <> wrote in message
    news:...
    > hello,
    >
    > I'm moving from the old ASP paradigm over to the new ASP.NET paradigm.
    > So far so good but I'm stumped on something that seems like it should
    > be really easy.
    >
    > In the old days you would use a single Record Set to populate a bunch
    > of controls all at the same time. For example, when a page loads it
    > reads from the database and populates a bunch of controls on a web
    > form.
    >
    > My question is: How do I do this in ASP.NET?
    >
    > I can't seem to figure out how to make a single call to the DB and
    > grab a single Row and then populate a bunch of labels based on the
    > results.
    >
    > Does anyone know of any good references or have any source that I can
    > see? I am using VB.NET.
    >
    > Thanks for your help in advance.
     
    Alvin Bruney, Sep 24, 2003
    #2
    1. Advertising

  3. karlid

    karlid Guest

    hello,

    Do you have sample source code of populating a dataset and binding a
    label to it?

    Sorry to ask but I'm really new to this stuff and I'm having some
    trouble with the syntax.
     
    karlid, Sep 24, 2003
    #3
  4. karlid

    karlid Guest

    A helpful person over at www.4guysfromrolla.com posted this solution:

    Dim strGetData as string = "SELECT * FROM myTable WHERE id = " &someID
    Dim conLU as new SQLConnection("yourConnectionStringGoesHere")
    Dim cmdGetData as new SQLCommand(strGetData , conLU)
    Dim drdGetData as SQLDataReader

    conLU.Open

    drdGetData = cmdGetData.ExecuteReader

    if drdGetData.Read() then
    myTextBox1.Text = drdGetData("value1")
    myTextBox2.Text = drdGetData("value2")
    end if

    conLU.Close
     
    karlid, Sep 24, 2003
    #4
    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. RockNRoll
    Replies:
    2
    Views:
    6,249
    Raterus
    Aug 4, 2004
  2. naijacoder naijacoder
    Replies:
    2
    Views:
    531
    naijacoder naijacoder
    Aug 30, 2004
  3. DKode
    Replies:
    3
    Views:
    668
    =?Utf-8?B?RGF2ZQ==?=
    Apr 29, 2005
  4. Dessip
    Replies:
    1
    Views:
    587
    Dessip
    Jul 5, 2006
  5. Biranchi Narayan Panda

    using ajax to show data in multiple labels one by one...

    Biranchi Narayan Panda, Feb 18, 2010, in forum: ASP .Net
    Replies:
    2
    Views:
    1,092
    Biranchi Narayan Panda
    Feb 20, 2010
Loading...

Share This Page