473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using a DataReader in VS NET

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
Nov 18 '05 #1
2 1111
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" <wa***************@wengert.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #2
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
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
2
by: Nathan Sokalski | last post by:
I have two OleDbDataReaders that I need to use at the same time. One of the DataReadersis used inside a While loop. My code is as follows: While eventreader.Read() ...
1
by: Brent | last post by:
I'm having a hard time wrapping my head around how to build a multi-dimensional array of n length out of a DataReader loop. Take this pseudo-code: ======================================= public...
3
by: Miguel | last post by:
Hi, I'm new to .NET and am using VB .NET as I am from a VB background. I am having difficulty understanding the way .NET handles, passes and uses objects. I have had a look at the Micrsoft Data...
2
by: Harry Strybos | last post by:
Hi All I have a form with about 20 check boxes and I want to persist their state to a single integer. That is to say, I want to set their Checked property to a particular bit value contained in...
2
by: jarod1701 | last post by:
Hi everyone, is there a way to access every record from a SqlDataReader via "foreach" ? I want to write a class which (besides doing some other stuff) retrieves a recordset using...
7
by: Diffident | last post by:
Hello All, I would like to use DataReader based accessing in my Data Access Layer (DAL). What is considered to be a best practice while returning from a DAL method that executes a query and...
2
by: sacha4 | last post by:
I need to make an edit page using data reader. this is my code.. Sub Page_Load() If Not IsPostBack Then Dim conn As SqlConnection Dim cmdSQL As SqlCommand ...
2
by: | last post by:
I am using a datareader to cycle through a list of records one at a time. I frequently get connection timeouts and am wondering what I am doing wrong. In more detail, I retrieve an excel...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.