Solved

ASP.NET VB running query against several servers times out.

Posted on 2011-03-02
7
272 Views
Last Modified: 2012-05-11
I have an asp.net vb app that will let you enter any query and run it against a single sql 2000 server or as many as 100 servers.  The results are displayed in a gridview.  This works great, unless it times out.  I have increased the connection timeout but still seem to have the same problem.  Thanks in advance for the help
VB Code ********
If RadioButton1.Checked = True Then 'All servers
                    myConnection = New SqlConnection("server=10.20.14.31;uid=user;pwd=pass;database=SCADA_DATA")
                    'establishing connection. you need to provide password for sql server
                    Try
                        myConnection.Open()
                        'opening the connection
                        myCommand = New SqlCommand("Select * from serverlist", myConnection)
                        'executing the command and assigning it to connection 
                        dr = myCommand.ExecuteReader()
                        While dr.Read()
                            'reading from the datareader
                            Dim VobServer As String = dr(1).ToString()
                            'MsgBox(VobServer)
                            'Start loop of new sql command
                            Try
                                If My.Computer.Network.Ping(VobServer) Then
                                    dbProvider = "provider = sqloledb;Data Source=" & VobServer & ";Initial Catalog=Windman;User ID=user;Password=pass"
                                    sql = txtQuery.Text
                                    con = New OleDb.OleDbConnection(dbProvider)
                                    con.Open()
                                    da = New OleDb.OleDbDataAdapter(sql, con)
                                    da.Fill(ds, "QueryResult")
                                    GridView1.DataSource = ds.Tables("QueryResult").DefaultView
                                    GridView1.DataBind()
                                Else

                                End If
                            Catch ex As Exception
                                'txtError.Text = ""
                                'txtDateTime.Text = ""
                                'txtError.Text = VobServer & " " & ex.Message
                                'txtDateTime.Text = Date.Now
                                'SqlDataSource1.Insert()
                            End Try
                            'displaying the data from the table
                        End While
                        dr.Close()
                        myConnection.Close()
                    Catch ex As Exception
                        'txtError.Text = ""
                        'txtDateTime.Text = ""
                        'txtError.Text = ex.Message
                        'txtDateTime.Text = Date.Now
                        'SqlDataSource1.Insert()
                    End Try
End If

Open in new window

0
Comment
Question by:NCSA SCADA
  • 4
  • 3
7 Comments
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35021478
Hi,

Try this

da.SelectCommand.CommandTimeout = 0

This will set NO TIME OUT for your query, but be careful because since there is no time out it could get stuck if the query does not respond.

Hope that helps
0
 

Author Comment

by:NCSA SCADA
ID: 35021724
Hmm ..... thanks - I will give it a try
0
 

Author Comment

by:NCSA SCADA
ID: 35021748
would it be placed after
da = New OleDb.OleDbDataAdapter(sql, con)
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35021777
Yes, just before you call the Fill method
0
 

Author Comment

by:NCSA SCADA
ID: 35021888
I still get an error.
Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out
0
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35021931
Ok, then, the error is getting from your ScriptManager,  try this, change your ScriptManaget tag in you markup  with this

<asp:ScriptManager ID="ScriptManager1" AsyncPostBackTimeOut="36000" runat="server" />
0
 

Author Closing Comment

by:NCSA SCADA
ID: 35022105
Thanks so much for the help.. have a good one
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now