all groups > dotnet academic > march 2006 >
You're in the

dotnet academic

group:

.net won't execute Sql Command


.net won't execute Sql Command Neo
3/17/2006 11:31:18 AM
dotnet academic:
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
Re: .net won't execute Sql Command pvdg42
3/18/2006 8:24:48 AM

[quoted text, click to view]

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?

Re: .net won't execute Sql Command Neo
3/20/2006 6:51:48 AM
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]
Re: .net won't execute Sql Command pvdg42
3/21/2006 12:41:36 PM

[quoted text, click to view]
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.

Re: .net won't execute Sql Command Neo
3/22/2006 5:16:28 AM
Finally Got it. Thatnks a lot!

[quoted text, click to view]
AddThis Social Bookmark Button