Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

simple question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kelly - 07 Dec 2007 22:21 GMT
I am from classic asp and learning asp.net.  In the past, once I have a
recordset retrieved, I can use it wheneve and wherever I want.  For example,
I know my recordset contains something like rs("firstname"), I can do
<%=rs("firstname")%> anywhere in the web page.  How do we achieve it in
asp.net?  

Sorry for the simple question, but please help.
Scott M. - 07 Dec 2007 23:04 GMT
Well, that question is actually a bit more complicated now, since in ASP
.NET and ADO .NET, we don't have recordsets any more.

If you are looking for a connected, read-only, and forward-only way of
iterating over your results, you can use a DataReader once you've executed
your command and then loop through it so you can see your returned records
one by one.

If you need to persist your data a bit longer than this, or if you need to
be able to back up through the records, ADO .NET provides us with a DataSet
(which is like an in memory relational database).  A DataSet is disconnected
from the source of the data so, you can access your data at any time after
populating your DataSet by accessing the table(s) of data that it contains
and then the Row(s) that you are interested in and finally the Item
(column/field) of that row.

Since the DataSet is a disconnected copy of the resultset, you can access
its data at any time throughout your code after you populate it.

-Scott

>I am from classic asp and learning asp.net.  In the past, once I have a
> recordset retrieved, I can use it wheneve and wherever I want.  For
[quoted text clipped - 4 lines]
>
> Sorry for the simple question, but please help.
Kelly - 08 Dec 2007 21:29 GMT
Thanks, Scott.  But what I want to achieve is to build my own html table and
have the data populated into the cells.  I know there are data bound controls
to use, such as gridview, repeater, etc.  But they cannot be freely modified
as I want, it seems to me.  For example, if I want to populate the stuff from
2 data sources into 1 html table, gridview, repeater controls won't work for
me.  I am looking for .net equivalent to <%=recordset("firstname")%>.  Is
that such a thing available?

> Well, that question is actually a bit more complicated now, since in ASP
> ..NET and ADO .NET, we don't have recordsets any more.
[quoted text clipped - 25 lines]
> >
> > Sorry for the simple question, but please help.
Scott M. - 09 Dec 2007 01:10 GMT
Again Kelly, I'll refer you to my first post.

If you want to be able to access the data anywhere in your page response,
you'll need to store it...and that means a Dataset.  Then, you can dig into
that DataSet and extract what you want, when you want.

-Scott

> Thanks, Scott.  But what I want to achieve is to build my own html table
> and
[quoted text clipped - 45 lines]
>> >
>> > Sorry for the simple question, but please help.
Peter Bromberg [C# MVP] - 08 Dec 2007 00:01 GMT
Kelly,
A good place to start for all this "Stuff" is the QUICKSTARTS tutorials
which installs with either Visual Studio or the .NET Framework SDK, or you
can use the online version at the ASP.NET Site:
http://quickstarts.asp.net/QuickStartv20/default.aspx

I don't want to sound like a broken MP3, but really - I've been doing .NET
since the first beta in 2000, and I still use the QUICKSTARTS today.
-- Peter
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

> I am from classic asp and learning asp.net.  In the past, once I have a
> recordset retrieved, I can use it wheneve and wherever I want.  For example,
[quoted text clipped - 3 lines]
>
> Sorry for the simple question, but please help.
Phil H - 08 Dec 2007 20:46 GMT
> I am from classic asp and learning asp.net.  In the past, once I have a
> recordset retrieved, I can use it wheneve and wherever I want.  For example,
[quoted text clipped - 3 lines]
>
> Sorry for the simple question, but please help.

I am inclined to agree with Peter Bromberg. As a piece of advice to
all former ASP programmers. Don't assume that ASP.NET is and extention
of ASP it isn't! It's a completely different platform.

The real underlying innovation is in Framework which draws together
experience from a variety of technologies and source languages. It's
great but it does require a lot of fresh learning from the developers
point of view.
John Timney (MVP) - 08 Dec 2007 21:16 GMT
Assuming firstname was the first item from the first row in the first
datatable in your dataset.
<%= mydataset.tables(0).rows(0).item(0)%>
or
<%= mydataset.tables(0).rows(1).item("firstname")%> will for example return
an item called firstname from the 2nd row in the 1st datatable in your
dataset

Binding in asp.net isn't the same as calling details from a recordset as
recordsets only had one result set in, where a dataset in asp.net can have
many tabels and results.

So, you would be better off executing code (in page_load for example) to
populate a string, int etc. and then binding to that in each of your
controls either as code in the method label1.text =
mydataset.tables(0).rows(0).item(0), or as <% =firstname %> inline.  Inline
code is not the recommended approach, even if the other way sometimes takes
more code.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

>I am from classic asp and learning asp.net.  In the past, once I have a
> recordset retrieved, I can use it wheneve and wherever I want.  For
[quoted text clipped - 4 lines]
>
> Sorry for the simple question, but please help.
Kelly - 08 Dec 2007 22:30 GMT
This is exactly what I want.  Thanks.

> Assuming firstname was the first item from the first row in the first
> datatable in your dataset.
[quoted text clipped - 29 lines]
> >
> > Sorry for the simple question, but please help.
Scott M. - 09 Dec 2007 01:13 GMT
Gee, I thought that's what I said.

> This is exactly what I want.  Thanks.
>
[quoted text clipped - 35 lines]
>> >
>> > Sorry for the simple question, but please help.
John Timney (MVP) - 09 Dec 2007 22:51 GMT
It was - I just converted it into beginner speak......lol

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

> Gee, I thought that's what I said.
>
[quoted text clipped - 38 lines]
>>> >
>>> > Sorry for the simple question, but please help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.