Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

.net won't execute Sql Command

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Neo - 17 Mar 2006 20:31 GMT
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?
pvdg42 - 18 Mar 2006 15:24 GMT
> 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?
Neo - 20 Mar 2006 15:51 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.