Timeout expired error when giving multiple conditions to sql query
-
Friday, March 16, 2012 10:37 AM
i tried command timeout and connection timeout in my vb.net 2003 application
but no result.
but same query successfully executing in sql server in 40 sec.
plz help me.
thanks in advance
All Replies
-
Friday, March 16, 2012 12:26 PMYou do probably something wrong.
Success
Cor -
Saturday, March 17, 2012 4:47 PM
Funny Cor ...
Raju, what Cor is trying to say is please show us the relevant code you're using.
~~Bonnie Berent DeWitt [C# MVP]
geek-goddess-bonnie.blogspot.com -
Tuesday, March 20, 2012 3:34 AMModerator
Hi raju_telangana,
Welcome to MSDN Forum.
Could you please post the code here? This is, so we can help you more effectively.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, March 20, 2012 9:05 AM
dim ConStr as string = "SERVER=_server;UID=_userid;PWD=_pwd;INITIAL CATALOG=_db;Connect Timeout=0"
Dim sqlConn As New SqlConnection(ConStr)
Dim sqlComm As SqlCommand
Dim myDA As New SqlDataAdapter
sqlConn.Open()
sqlComm = New SqlCommand
sqlComm.Connection = sqlConn
sqlComm.Parameters.Clear()
sqlComm.CommandText = _QryString
sqlComm.CommandType = CommandType.Text
sqlComm.CommandTimeout = 0
myDA.SelectCommand = sqlComm myDA.Fill(myDS, "Myds")'_QryString is a big query having multiple joins with tables having large data.
'in that query if i pass many values around 50 + values to C.WORKID clause shown in below
' am getting timeout error.
_query as string = " SELECT column1,column2 from ......... INNER JOIN TBLCASE C ON C.EMPLOYERID = CJ.EMPLOYERID AND
C.WORKID in ('336','8','338') ......"
raju
-
Tuesday, March 20, 2012 2:39 PM
With both Connection Timeout and Command Timeout set to 0, there will be no timeout exceptions at all ... it will wait indefinitely to connect and/or it will wait indefinitely to perform the command.
That means your timeout error is happening elsewhere. Are you using WCF? What is the exact exception message you're getting? Could you post it here ....
~~Bonnie Berent DeWitt [C# MVP]
geek-goddess-bonnie.blogspot.com -
Wednesday, March 21, 2012 9:42 AM
this is what am getting as error:
time out expired.the time out period elapsed prior to completion of the operation or the server is not responding.
Thanks for help.
raju
-
Wednesday, March 21, 2012 1:41 PM
How much time it takes to execute this query in Sql Server Management Studio?
This is possible that, after a fixed amount of time, Your Sql Server Engine is throwing a Time-Out Exception.To verify Just a check if your Sql server's Remote Query execution time out is causing the issue. You can verify that by opening Properties of SqlServer
If you are using Sql Server 2008 Sp1, There is a reported bug of TemeOut issue swith a work around as below.
Lingaraj Mishra
-
Friday, March 23, 2012 6:01 AM
Raju,
Your code should not run, it contains a VB syntax error are you sure you are not clicking rung with older version or something like that.
Success
Cor -
Saturday, March 24, 2012 4:44 PMCor -- what is wrong with that code? It looks fine to me -- although it should be on another line, but I don't think VB cares about that. If you're getting a syntax error just because myDS does not exist in the snippet of code shown, it could be that in Raju's code it's defined and instantiated elsewhere, but you didn't do that in your test.
~~Bonnie Berent DeWitt [C# MVP]
geek-goddess-bonnie.blogspot.com -
Wednesday, March 28, 2012 1:49 AMModerator
Hi raju_telangana,
Have you solved the issue?
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
-
Wednesday, March 28, 2012 2:31 AMWhat line of the code presented throws the error? The myDA.Fill or the sqlConn.Open()?
Brent Spaulding | Access MVP
-
Wednesday, March 28, 2012 2:41 AM
>> It looks fine to me -- although it should be on another line, but I don't think VB cares about that <<
The CR/LF in VB is analogous to the ; in C#. So ... the myDA.Fill() should definately be on a new line. VB tells you "End of Statement Expected" with code that looks like Cor's and Raju's.
Brent Spaulding | Access MVP
-
Wednesday, March 28, 2012 4:29 AM
Thanks Brent ... VB syntax throws me for a loop sometimes and I don't even have VB installed on my computer so I can never test any of it anyway. ;0)
Could be the formatting wasn't right in Raju's post simply because of the horrendous formatting on these forums sometimes ... drives me nuts!
~~Bonnie Berent DeWitt [C# MVP]
geek-goddess-bonnie.blogspot.com -
Thursday, March 29, 2012 3:02 AM
>> Thanks Brent ... VB syntax throws me for a loop sometimes <<
You'd think with my experience with VBA, VB would be 'Natural" ---- but its not! I think my brain needed the significance of the C# differences in order to learn something new! I found that as I wrote VB, I tried to still think in VBA -- then convert to VB, but with C#, I just learned (term used loosely :) ) C#.
>> Could be the formatting wasn't right in Raju's post simply because of the horrendous formatting on these forums sometimes ... drives me nuts! <<
Definately agree with you there!
Brent Spaulding | Access MVP
-
Thursday, March 29, 2012 7:07 AM
Bonnie,
To give you personally an answer, older versions of VB don't care about that but since VB7 (2002) procedures should be set between parenthesis. This was already in older versions done in a very strange way where it sometimes should be done and in some other methods (as far as I remember me void for you) could be done.
Currently all arguments have to be between parenthesis when a method is used.
Be aware that VB has no syntax-line delimiter like in C# (the semicolon) and in the newer versions in most situation also no continuation character anymore like in past.
So it could not have to do with the forum pasting.
Success
Cor- Edited by Cor LigthertMVP Thursday, March 29, 2012 7:08 AM
-
Thursday, March 29, 2012 3:03 PM
I've never used VB ... not in the "old days" and not really even with VBA. I can read it ok (most of the time), but trying to write it off the top of my head (for a forum post) doesn't always work so well. Unless it's something pretty straightforward, I'll typically write it in C# and use an online converter to convert to VB.
My background language before I started with .NET/C# (in 2002) was FoxPro.
~~Bonnie Berent DeWitt [C# MVP]
geek-goddess-bonnie.blogspot.com -
Friday, March 30, 2012 8:11 AM
I've no difficulties with both not even using them inside a time span after each other in a scope of 10 minutes, if I use C# I try to write accepted conventional correct C# and if I use VB the same with the accepted conventions used in VB.
Therefore does code made by most online converters always pain in my eyes because it is mostly only straight forward translated. I don't know if you speak more natural languages, but also converting languages is not only words.
For instance a Dutch name "de Wit" (In fact Holland) would be translated in English to "The White", however as a name it would be probably in America once be registered like "DeWitt". A Dutch name "Berend" (in Fact Frysian) would probably been registered in the USA as Berent.
:-)
The converters from Tangientsolutions however are often also conventional not so bad as most.
As example in Code
DataTable datatable = new DataTable();
is translated by many converters like
Dim datatable as DataTable = new DataTable()
While in VB newer then version 2002 it has to be
dim dt as New DataTable 'watch the non case sensitivity
Success
Cor
- Edited by Cor LigthertMVP Friday, March 30, 2012 8:11 AM
- Edited by Cor LigthertMVP Friday, March 30, 2012 8:12 AM
- Edited by Cor LigthertMVP Friday, March 30, 2012 8:12 AM
- Edited by Cor LigthertMVP Friday, March 30, 2012 8:15 AM
-
Friday, March 30, 2012 2:36 PM
I typically use Developer Fusion for my conversions (http://www.developerfusion.com/tools/convert/csharp-to-vb/ or http://www.developerfusion.com/tools/convert/vb-to-csharp/) They give the correct translation for the example you gave.
My old name, Berent, is actually Polish. My ex-husband is from 100% Polish ancestry. His family insists that it was always Berent and not something different in "the old country". ;0)
You're right about my new name, DeWitt --- it is of Dutch origin. We finally got around to getting married (last month) after being together for 12 years. =0)
~~Bonnie Berent DeWitt [C# MVP]
geek-goddess-bonnie.blogspot.com -
Saturday, April 07, 2012 10:40 PM
The converters from Tangientsolutions however are often also conventional not so bad as most.
Hey Cor --- do you have a url for that? I tried to Google it and couldn't come up with anything that looked right. I'd like to add it to my list of converters. Thanks!
~~Bonnie Berent DeWitt [C# MVP]
geek-goddess-bonnie.blogspot.com

