Using a DataReader in VS NET

W

Wayne Wengert

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
 
W

Wayne Wengert

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
 
C

Cor

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
 

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

Top