one sql call - multiple labels populated?

K

karlid

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.
 
A

Alvin Bruney

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
 
K

karlid

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.
 
K

karlid

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top