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
[quoted text, click to view] "pvdg42" wrote:
>
> "Neo" <Neo@discussions.microsoft.com> wrote in message
> news:F9E975A5-F4B6-4DF7-B3E8-33BCFF8F3AEF@microsoft.com...
> > is there any reason why a sql command will execute in sql server and not
> > in
> > Vb.Net?
> > It takes about 1.5 minutes to execute.. Would the timeout have anything to
> > do with it? If so how do I increase it?
>
> Can you provide some details, please?
> How are you sending this SQL query to the database (DataAdapter?), and what
> is the error message you receive when it fails?
>
>
[quoted text, click to view] "Neo" <Neo@discussions.microsoft.com> wrote in message
news:A798C479-40C0-4B40-B948-67D681BD6422@microsoft.com...
> 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
>
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.