Solved

How to avoiding time out expired in VB 2008

Posted on 2011-03-23
15
539 Views
Last Modified: 2012-05-11
Today you send me a solution using BackgroundWorker and it worked, but in my routine there is a lot of stored procedures and in a certais time I received the messege below:
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

In adicction I have to say that in the begining I had only one procedure, but, because of this problem I divided  the procedure. In spite of this I can´t still avoid the time out.

Thanks for your help.
0
Comment
Question by:JGonzaga
  • 6
  • 6
15 Comments
 
LVL 4

Expert Comment

by:MaximumIQ
ID: 35200478
you can add "Connect Timeout"  and value in seconds to your connection string.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.71).aspx
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 125 total points
ID: 35306470
Did you try the above suggestion?
0
 

Author Comment

by:JGonzaga
ID: 35306528
Yes I´ve tried it but sometimes the time out expired still occurs. Ono of the experts told me that the problem coud be in the data base. So i´ve done a new question about SQL database becouse I heven´t realized that the correct way to procced should be redirect this question  to another zones (i´m a beginner in EE) .

sorry, I think that is better close this question.



0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 125 total points
ID: 35306564
Trying using connectiontimeout in the connection string but also set the COMMANDTIMEOUT property of the SQLCOMMAND object to a bigger value

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx
0
 

Author Comment

by:JGonzaga
ID: 35306684

where I do this? On the code or on the database configuration?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35306693
On the SqlCommand object that is being used to interact with the DB.
0
 

Author Comment

by:JGonzaga
ID: 35306771
Please could you be more specific?

I´m not a professional programer. I used to work with MSAcces and I´m just beginner with Vb 8 and MySql

I will be very grateful if you give the basic steps.

Thanks a lot.

 
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35309680
Show me the code you are using currently.
0
 

Author Comment

by:JGonzaga
ID: 35314045
This is the code. Before the procedure I have problem I put a comment.

Thanks for your help.
If Mid(MTabela, 1, 4) = "SPF_" Then
                            Dim cmd As New MySqlCommand
                            Dim parametro As New MySqlParameter
                            parametro.ParameterName = "Parquivo"
                            parametro.Value = NumArquivo
                            Try
                                cmd.Connection = Conn
                                cmd.CommandType = CommandType.StoredProcedure
                                cmd.Parameters.Add(parametro)
                         
				' This procedures makes a lot of things in big tables and sometimes time out expired occurs
                                cmd.CommandText = "ProcGeraLivros"
                                cmd.ExecuteNonQuery()
                            Catch ex As Exception
                                MessageBox.Show("Erro ProcGeraLivros." & ex.Message, "Gera Livros")
                            End Try
                        Else
                            Dim cmd As New MySqlCommand
                            Dim parametro As New MySqlParameter
                            parametro.ParameterName = "PIndEsc"
                            parametro.Value = MIndEsc
                            Try
                                cmd.Connection = Conn
                                cmd.CommandType = CommandType.StoredProcedure
                                cmd.Parameters.Add(parametro)
                                cmd.CommandText = "ProcGeraPlanoContas"
                                cmd.ExecuteNonQuery()
                            Catch ex As Exception
                                MessageBox.Show("Erro ProcGeraPlanoContas." & ex.Message, "Gera Plano de contas")
                            End Try
                        End If

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35314071
Add the

cmd.CommandTimeOut = 32000

before ExecuteNonQuery()
0
 

Assisted Solution

by:JGonzaga
JGonzaga earned 0 total points
ID: 35314101
Thanks. I´ll try this.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35315435
Why did not you just accept an answer?
0
 

Author Closing Comment

by:JGonzaga
ID: 35356856
It was a great solution. I´m very greateful
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

790 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