Well, as of now, I am sending the command via a SqlCommand which I then load
into the sqlDataReader. I choose this approach because it was the only way I
could increase the timeout. Now the problem is loading the reader into a
datagrid!
Every Site i went to said to use this method:
datagrid.datasource = myReader
datagrid.databind()
This is my current code:
myCommand.CommandTimeout = 130
myConn.Open()
myReader = myCommand.ExecuteReader()
dgDisplay.DataSource = myReader
.......and this is the error I get
An unhandled exception of type 'System.Exception' occurred in
system.windows.forms.dll
Additional information: Complex DataBinding accepts as a data source either
an IList or an IListSource
I don't know why so many people have said to do this when databind is now a
property of datagrid.
Thanks again
> > is there any reason why a sql command will execute in sql server and not
> > in
[quoted text clipped - 5 lines]
> How are you sending this SQL query to the database (DataAdapter?), and what
> is the error message you receive when it fails?
pvdg42 - 21 Mar 2006 19:41 GMT
> Well, as of now, I am sending the command via a SqlCommand which I then
> load
[quoted text clipped - 26 lines]
> property of datagrid.
> Thanks again
As the various command objects that are part of a SQLDataAdapter object are
themselves SqlCommand objects, I think you should be able to change the
CommandTimeout property and create a DataSet, which will serve as the data
source for your grid.
A DataReader will not work as the data source for a grid, hence the error
message.
DataReaders are designed to be accessed sequentially, using the Read()
method.
Neo - 22 Mar 2006 14:16 GMT
Finally Got it. Thatnks a lot!
> > Well, as of now, I am sending the command via a SqlCommand which I then
> > load
[quoted text clipped - 35 lines]
> DataReaders are designed to be accessed sequentially, using the Read()
> method.