Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to avoiding time out expired in VB 2008

Posted on 2011-03-23
15
Medium Priority
?
562 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

618 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