Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using a DataReader in VS NET

Reply
Thread Tools

Using a DataReader in VS NET

 
 
Wayne Wengert
Guest
Posts: n/a
 
      01-22-2004
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


 
Reply With Quote
 
 
 
 
Wayne Wengert
Guest
Posts: n/a
 
      01-22-2004
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
"Wayne Wengert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      01-22-2004
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
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trailing empty space added when using Repeater and DataReader Andrei Pociu ASP .Net 4 10-14-2004 06:16 PM
Search record by using Datareader y_rkumar@hotmail.com ASP .Net 1 11-25-2003 05:28 PM
Search record by using Datareader y_rkumar@hotmail.com ASP .Net 0 11-25-2003 11:02 AM
Search record by using Datareader y_rkumar@hotmail.com ASP .Net 0 11-25-2003 11:00 AM
Using two Datareader Randall ASP .Net 3 10-29-2003 02:58 PM



Advertisments