473,609 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datareader binding to datagrid not working

I am using VS 2003 and trying to build a standalone application. I have
been writing all my asp.net work using DW and am just now trying to build a
application that will read some of the tables I had written out from my web
apps.

I can get my DataReader to read my data fine. But I wanted to use a
DataGrid, but it is apparently completely different????

I can do:

DataGrid1.DataS ource = dbReader
DataGrid1.DataB ind()

I get an error saying something about: "Complex DataBinding accepts as a
data source either an IList or an IListSource".

There also doesn't seem to be a DataBind() method to this DataGrid?

Why doesn't it work?

Can I not make a standalone program using the same techniques as I do in my
Web pages (asp.net)?

Thanks,

Tom
Jan 26 '06 #1
3 3344
tshad wrote:
I am using VS 2003 and trying to build a standalone application. I have
been writing all my asp.net work using DW and am just now trying to build a
application that will read some of the tables I had written out from my web
apps.

I can get my DataReader to read my data fine. But I wanted to use a
DataGrid, but it is apparently completely different????

I can do:

DataGrid1.DataS ource = dbReader
DataGrid1.DataB ind()

I get an error saying something about: "Complex DataBinding accepts as a
data source either an IList or an IListSource".

There also doesn't seem to be a DataBind() method to this DataGrid?

Why doesn't it work?

Can I not make a standalone program using the same techniques as I do in my
Web pages (asp.net)?

Thanks,

Tom


You can not bind a datareader to a datasource. You will need to either
load it into a datatable by looping through the datareader or use a
dataadapter to do what you want.

chris
Jan 26 '06 #2

"I Don't Like Spam" <no@spam.com> wrote in message
news:OH******** ******@TK2MSFTN GP14.phx.gbl...
tshad wrote:
I am using VS 2003 and trying to build a standalone application. I have
been writing all my asp.net work using DW and am just now trying to build
a application that will read some of the tables I had written out from my
web apps.

I can get my DataReader to read my data fine. But I wanted to use a
DataGrid, but it is apparently completely different????

I can do:

DataGrid1.DataS ource = dbReader
DataGrid1.DataB ind()

I get an error saying something about: "Complex DataBinding accepts as a
data source either an IList or an IListSource".

There also doesn't seem to be a DataBind() method to this DataGrid?

Why doesn't it work?

Can I not make a standalone program using the same techniques as I do in
my Web pages (asp.net)?

Thanks,

Tom
You can not bind a datareader to a datasource. You will need to either
load it into a datatable by looping through the datareader or use a
dataadapter to do what you want.

Is that something that something that you can only do in a web page? I
databind datareaders to a datagrid all the time?

Tom
chris

Jan 26 '06 #3
Thsad,

Although that the grid have in net 1.x for ASPNET and Windowforms the same
name (DataGrid), do they act completely different (in Net 2.0 the new Grids
have different names, it is probably not for nothing that this confusing
thing is now done well).

However there are some things the same. The ASPNET datagrid accepts a
DataReader, a Datatable and a DataSet. A windowform DataGrid (in theory more
however in fact) only the last two.

To see a lot of samples about the datagrid can you look on our (non
commercial) website.

http://www.vb-tips.com/default.aspx

I hope this helps,

Cor

"tshad" <ts**********@f tsolutions.com> schreef in bericht
news:uZ******** ******@TK2MSFTN GP15.phx.gbl...
I am using VS 2003 and trying to build a standalone application. I have
been writing all my asp.net work using DW and am just now trying to build a
application that will read some of the tables I had written out from my web
apps.

I can get my DataReader to read my data fine. But I wanted to use a
DataGrid, but it is apparently completely different????

I can do:

DataGrid1.DataS ource = dbReader
DataGrid1.DataB ind()

I get an error saying something about: "Complex DataBinding accepts as a
data source either an IList or an IListSource".

There also doesn't seem to be a DataBind() method to this DataGrid?

Why doesn't it work?

Can I not make a standalone program using the same techniques as I do in
my Web pages (asp.net)?

Thanks,

Tom

Jan 26 '06 #4

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

Similar topics

1
3269
by: Al | last post by:
in order to implement sorting, paging in a datagrid, can I have the datasource of the datagrid a datareader or it must be a dataset then I create a dataview and make it a datasource of the datagrid? The reason I am asking this question is because I already created a datagrid and made its datasource a datareader, yet, could not implement sorting or paging. Any idea of how to approach it . thanks
5
5752
by: Jason Huang | last post by:
Hi, Is it possible to bind DataReader to a DataGrid in C# windows form? And how? And can we update data in a DataSet by using the DataReader? Thanks for help. Jason
2
1120
by: Wayne Wengert | last post by:
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...
1
1552
by: BC | last post by:
Hi, Been searching the newgroups but haven't found an answer. I'm used to binding disconnected ADO recordsets to Datagrid controls and tweaking the Datagrid to suit my needs (columnheader, columnwidth, etc.) Now I'm using vb.net, and I'm tryint to do the same
12
467
by: Thomas Scheiderich | last post by:
I have 2 dropdowns that are exactly the same and I don't want to re-read for each. Is there a way to do something like below where I read the data, bind to depCity1 and then bind to destCity2. I find that the second one always is blank. I assume this is because the DataReader is read-forward only. ******************************************************** connect.open() cmdSelect = New OleDbCommand("exec populateCities 'North...
1
1214
by: Jack Black | last post by:
Hi, all! I have a populated Reader that I'm binding to a data grid, and I'm trying to figure out how I can edit cells BEFORE binding the reader to the DataGrid. Of the few pieces of sample code I've seen a DataSet is required, and I really don't want to dump a lot of code into something that may not need it: a quick bind to a reader dumps data perfectly with zero hassle! ;-) Obviously the Reader is (duh) read only, so I was wondering...
4
4317
by: Shapper | last post by:
Hello, I have created a datareader function in a asp.net/vb web site. The datareader returns only one record with 2 fields: and In the same aspx.vb I want to use this values as follows: myImage.ImageURL = myImage.Text =
4
3511
by: hazz | last post by:
The data access layer below returns, well, a mess as you can see on the last line of this posting. What is the best way to return customer objects via a datareader from the data layer into my view and bind them to a datagrid using BindingList. I am in need of an epiphany here. Thank you. -Greg ******************BIND ARRAY OF CUSTOMER OBJECTS TO DATAGRID ************************ private Customer c; c =...
3
2823
by: dotComPaJi | last post by:
I have recently joined a company and while looking at the source code I did find the following: They were accessing data from database using dataReader and after that passing it to List Class. then accessing that data ( i,.e in List Box, dataGrid etc) I was thinking that there is no need to pass it to List Class. Any suggestions would be appreciated. Also they were doing the same with dataSet..passing it to datatable.
0
8076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8573
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8541
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8222
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8406
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7002
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4021
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.