Home All Groups Group Topic Archive Search About

Datareader binding to datagrid not working

Author
26 Jan 2006 2:41 AM
tshad
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.DataSource = dbReader
DataGrid1.DataBind()

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

Author
26 Jan 2006 2:46 AM
I Don't Like Spam
tshad wrote:
Show quoteHide quote
> 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.DataSource = dbReader
> DataGrid1.DataBind()
>
> 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
Author
26 Jan 2006 2:58 AM
tshad
Show quote Hide quote
"I Don't Like Spam" <no@spam.com> wrote in message
news:OH0LCLiIGHA.3984@TK2MSFTNGP14.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.DataSource = dbReader
>> DataGrid1.DataBind()
>>
>> 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

Show quoteHide quote
> chris
Author
26 Jan 2006 5:54 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"tshad" <tscheider***@ftsolutions.com> schreef in bericht
news:uZ5LPIiIGHA.2704@TK2MSFTNGP15.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.DataSource = dbReader
> DataGrid1.DataBind()
>
> 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
>
>