473,699 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

timeout Expired when trying to do a 'where' or filter recordset

Hi all...
I've been stumped by this for days. Bit of ASP code: (IIS)

Set LocalConn = CreateObject("A DODB.Connection ")
LocalConn.Curso rLocation = adUseClient
LocalConn.Comma ndTimeout = 0
LocalConn.Open sConnStringSO (SQL Server 2000, irrelevant what it is,
see below).

LocalConn.Error s.Clear

CountDuplicates SQL = "select * from dbo.tbl1 WHERE DESC LIKE 'aaa'"
oRss.Open
CountDuplicates SQL,LocalConn,a dOpenDynamic,ad LockReadOnly,ac CmdText
this hangs and then results with "timeout expired".

the same SQL works flawlessly if tested on query analyzer, with the
same connection Login.

And I found, that If I remove the WHERE clause, it works without
problems..., both in ASP and Query analyzer.

I have another connection running in parallel to this one, Server
side, but to a different database on the same server. If I disable it,
the above code works. But, I need it open all the time...
if its the two connections conflicting, how come the code above works
with a simple Select but not with a WHERE criteria on it, under the
same two connection conditions?

~Thanks for insights.

Jul 23 '05 #1
9 3718
heruti (he****@lycos.c om) writes:
I've been stumped by this for days. Bit of ASP code: (IIS)

Set LocalConn = CreateObject("A DODB.Connection ")
LocalConn.Curso rLocation = adUseClient
LocalConn.Comma ndTimeout = 0
LocalConn.Open sConnStringSO (SQL Server 2000, irrelevant what it is,
see below).

LocalConn.Error s.Clear

CountDuplicates SQL = "select * from dbo.tbl1 WHERE DESC LIKE 'aaa'"

oRss.Open
CountDuplicates SQL,LocalConn,a dOpenDynamic,ad LockReadOnly,ac CmdText

this hangs and then results with "timeout expired".

the same SQL works flawlessly if tested on query analyzer, with the
same connection Login.
It does? I get a syntax error from it:

Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'DESC'.

Apart from that, I don't understand why you specify a dynamic cursor. Since
you use a client-side cursor, static is all you can get anyway. I would
somehow suspect that you get a dynamic server-side cursor anyway, and
this is part of your problems.
I have another connection running in parallel to this one, Server
side, but to a different database on the same server. If I disable it,
the above code works. But, I need it open all the time...
if its the two connections conflicting, how come the code above works
with a simple Select but not with a WHERE criteria on it, under the
same two connection conditions?


Apparently a blocking issue. And not knowing what your databases and
connections are up to, I cannot really say more. But you can use sp_who
to verify that you have a blocking issue. If you see a non-zero value
in the Blk column, that spid is blocking the spid on that row.

To get more detailed information about the blocking situation, my
aba_lockinfo can help you. It's on
http://www.sommarskog.se/sqlutil/aba_lockinfo.html.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

Erland Sommarskog wrote:
LocalConn.Error s.Clear

CountDuplicates SQL = "select * from dbo.tbl1 WHERE DESC LIKE 'aaa'"

oRss.Open
CountDuplicates SQL,LocalConn,a dOpenDynamic,ad LockReadOnly,ac CmdText

this hangs and then results with "timeout expired".

the same SQL works flawlessly if tested on query analyzer, with the
same connection Login.
It does? I get a syntax error from it:

Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'DESC'.

Apart from that, I don't understand why you specify a dynamic cursor.

Since you use a client-side cursor, static is all you can get anyway. I would somehow suspect that you get a dynamic server-side cursor anyway, and
this is part of your problems.


I have tried static, ForwardOnly and most of the other combinations
(out of despair..) but the problem apparently is not there but in the
other, locking, connection.
well perhaps you don't have the DESC field in your table... or the tbl1
table.
in Any case, here are more details on the connections:

the first connection:

sconString=
"Provider=SQLOL EDB; User ID=xxx;Password =yyy;Initial Catalog=eeee;Da ta
Source=aaa;"

Set oCon = CreateObject("A DODB.Connection ")
oCon.Open sConString
oCon.Errors.Cle ar

oCon.BeginTrans

If oCon.State = adStateOpen Then OpenConn = True

the second connection:
function openSecondConn( )

sConString2 =
"Provider=SQLOL EDB; User ID=xxx;Password =yyy;Initial Catalog=zzz;Dat a
Source=bbb;"

Set oConClientRs = CreateObject("A DODB.Connection ")
oConClientRs.Cu rsorLocation = adUseClient
oConClientRs.Op en sConString2
oConClientRs.Er rors.Clear

end function

And after this:

the ASP client runs several stored procedures on database aaa, with
this function:
Function ExecuteSP(sProc ,arrParams)

Dim nCnt
Dim nParamMax
Dim nMax

On Error Resume Next

ExecuteSP = False

If Not oCon.State = adStateOpen Then
m_sErrorData = "No active connection"
RollbackTrans()
Exit Function
End If
nMax = UBound(arrParam s)

If Not IsObject(oCom) Then

Set oCom = CreateObject("A DODB.Command")

With oCom
..ActiveConnect ion = oCon
..CommandType = adCmdStoredProc
End With

End If

With oCom

..CommandText = sProc

..Parameters.Re fresh

nParamMax = .Parameters.Cou nt - 1 'minus one for return param

'check to see if we have passed the correct number of parameters
If Not nParamMax = nMax + 1 Then
m_sErrorData = "Incorrect number of parameters. Passed: " & nMax +
1 & " Required: " & nParamMax
RollbackTrans()
Exit Function
End If

For nCnt = 0 To nMax

..Parameters.It em(nCnt+1).valu e = arrParams(nCnt)

Next

..Execute

nRet = .Parameters(0)

End with
' error handling code snipped off, irrelevant
ExecuteSP = True

End Function

then, I'm trying to run the code that gets stuck:

openSecondConn( sConnString2)
Set oRss = CreateObject("A DODB.Recordset" )

CountDuplicates SQL = "select count (*) as cnt from dbo.tbl1 WHERE Desc
LIKE 'qqqq'"

oRss.Open
CountDuplicates SQL,oConClientR s,adOpenStatic, adLockReadOnly, acCmdText

hangs...

but why, if its the other connection locking it up, does it still work
when I remove the 'where' criteria?
can it at least fail thoroughly, is it too much to ask?...

Jul 23 '05 #3
Also forgot to mention,

the first connection (server side) runs with transactions, where it
begintrans'es in the start of a session and commits only at the end. in
between I want to run the above open operation with the second
connection, without transactions (preferably but I have tried both
ways, didn't work), on a static (or keyset) client side cursor,
Thanks

Jul 23 '05 #4

heruti wrote:

And a final note:

due to my stupidity probably, I didn't realise that the stored
procedure called just before my hanging function manipulates the same
table.
But it is finished, so isn't it possible to nest transactions?

my situation is complicated by the fact that, all stored procedures in
the project are stored on a different database than the one holding the
data tables (hence the two different connections). Its too complicated
to change that (there are over 50 storedprocs).
But, does a transaction Begintrans / commit also work when you are,
within it, calling stored procedures on one database that manipulate
data on another database (same server though).??
if not, the first connection doesn't really benefit from the
Transaction processing and I can remove the begintrans/commit...

Jul 23 '05 #5
heruti (he****@lycos.c om) writes:
And a final note:

due to my stupidity probably, I didn't realise that the stored
procedure called just before my hanging function manipulates the same
table.
But it is finished, so isn't it possible to nest transactions?
Not sure what you mean, but if you say:

BEGIN TRANSACTION

BEGIN TRANSACTION

COMMIT TRANSACTION

COMMIT TRANSACTION

nothing really gets committed until the outermost COMMIT statement is
executed. Until that COMMIT only decrements the transaction count. This
means that all locks acquired during the transaction are still there.

So if that connection to bbb excutes stored procedures that operates on
data in aaa, and that connection never commits until it exists, I am not
surprised that you get blocking problems.
my situation is complicated by the fact that, all stored procedures in
the project are stored on a different database than the one holding the
data tables (hence the two different connections). Its too complicated
to change that (there are over 50 storedprocs).
So instead you run into to complications that you don't even understand?
Sounds to me that a cleaning-up would be a good thing to do!

In any case that is not reason for two different connections. You can
be in one database and call stored procedures in another. Just prefix
with database name: aaa.dbo.some_sp . Ah, you are using .Parameters.Ref resh!
This makes life simpler, but it's not the most effecient way to call
a stored procedure anyway.

If you must use .Refresh, you should definitely move those stored
procedures.
But, does a transaction Begintrans / commit also work when you are,
within it, calling stored procedures on one database that manipulate
data on another database (same server though).??


Not sure what you really mean, but a transaction spans databases.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #6
thank you for your response...

I have solved the problem by most awkwardly way of temporarily storing
in an array the data to be written in the blocked function, until later
when the first transaction is commited and then executing this
function. .

But still, this seems a most roundabout and illogical way to do things
in the 21st century (I seem to remember somewhere in the Renessance
period, databases were better! ask Leonardo...)

Am I really to believe, that if you open a server side connection and
transaction to database A, in which you execute with ADO some stored
procedures on it that manipulate data on database B, you must end this
transaction before you can open any other client side connection to the
database B?
(I need another connection, because I have to use ADO to write records,
which only works with client side recordset. The first transaction uses
server side).

Like this:
OPEN CONNECTION 1 TO DB. A (SERVER SIDE)
BEGIN TRANSACTION (A)
..
..
[execute stored procs on database A, which manipulate
data on DB. B, tables A1, A2, A3...]

BEGIN TRANSACTION (B)
OPEN CONNECTION 2 TO DB. B

[ read/write records with ADO directly Tables A1, A2, A3..
LOCKED....!!!]
COMMIT TRANSACTION B

COMMIT TRANSACTION A

and regarding the .Parameters.Ref resh,
it was there before I came to the project. does it have any special
consequences?

Jul 23 '05 #7
heruti (he****@lycos.c om) writes:
I have solved the problem by most awkwardly way of temporarily storing
in an array the data to be written in the blocked function, until later
when the first transaction is commited and then executing this
function. .

But still, this seems a most roundabout and illogical way to do things
in the 21st century (I seem to remember somewhere in the Renessance
period, databases were better! ask Leonardo...)
Yes, this an akward and complicated way of doing things. But it appears
that this is because you've taken akward way to start with. Maybe you
should go back and re-design the original setup with two connections.

If you have to transactions that access the same data, and one has a
transaction that does not commit, then they will interfer with each
other.

I can't really say much more, because there is so much that I don't
know about your system, since you have not been very good at sharing
information. It is possible that you can keep the current scheme with
proper indexing, and knowing what you update etc. But I don't really
like to guess what you are doing.

I should add that you can actually share a transaction between two
connection. This is something I have not dug into myself, but I believe
the system procedure sp_bindsession is part of the plot. However, this
would just add one more kludge to your system, and you seem to have
too many already.
(I need another connection, because I have to use ADO to write records,
which only works with client side recordset. The first transaction uses
server side).
I don't know why you use server-side cursors at all. Client-side
recordsets usually perform better, and causes less confusion.
and regarding the .Parameters.Ref resh,
it was there before I came to the project. does it have any special
consequences?


That's a roundtrip to the server to get the parameter profile.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #8

I usually don't think it appropriate to burden readers, who are
gracious enough to help, with all of the jumbalaya of my code.

I thought perhaps it was something basic, like maybe one cannot have a
server side SQL process and a client side process on two different
connections to the same table (if this is impossible I am not sure of
till now anyway)

Thank you for your efforts.

I haven't really understood how a lock on a table can so partial as to
allow a SELECT but time our on a SELECT WHERE, but perhaps its a bug in
the Locking system...

Jul 23 '05 #9
heruti (he****@lycos.c om) writes:
I usually don't think it appropriate to burden readers, who are
gracious enough to help, with all of the jumbalaya of my code.

I thought perhaps it was something basic, like maybe one cannot have a
server side SQL process and a client side process on two different
connections to the same table (if this is impossible I am not sure of
till now anyway)

Thank you for your efforts.

I haven't really understood how a lock on a table can so partial as to
allow a SELECT but time our on a SELECT WHERE, but perhaps its a bug in
the Locking system...


You still seem to be prone to give SQL Server the blame for your problems.
Believe me, your problem is in the overall architecture of your application.

I cannot answer why you first got the problem when you added the WHERE
clause. But now I have a strong feeling that I don't even know half of
your story, I don't even find it a mystery. I could think of a number of
possible reasons, but I have too little knowledge to find it worthwhile
to present any speculations.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
19825
by: David Morgan | last post by:
Hello In my ASP page I am trying to ascertain whether a randomly generated ID starts with certain characters that are not allowed or has been used before. When the SQL statement for latter is executed I get: Microsoft OLE DB Provider for SQL Server error '80040e31' Timeout expired
4
3923
by: Paul | last post by:
I sometimes get a timeout error when populating my datagrid, the code is WizardConnection.Open() UpdateCommand.CommandText = "EXECUTE sp_assign_user '" & PhysOffice.SelectedValue & "', '" & Context.User.Identity.Name & "'" UpdateCommand.ExecuteNonQuery()
2
4584
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET Here's the scenario: 1. .NET Windows Client on a remote machine makes a web service call to update tables on a Web Server running SQL Server 2000. 2. The Update is updating about 1000 - 3000 records doing simple update statements like "Update...
4
4377
by: Nevyn Twyll | last post by:
I've been working on an asp.net application and everything's been great. But suddenly, whether I'm tyring to use a database on my own machine, or on my server, I'm getting a timeout when trying to open a database connection. The error seems to happen regardless of what ASP.NET app I'm working with/trying to debug. It will open a few connections, Here's the error:
0
1611
by: gak999 | last post by:
I have list box showing list of worksheet with double click event: Dim rs3 As Object Set rs3 = Me.Recordset.Clone rs3.FindFirst " = " & Str(Me!) Me.Bookmark = rs3.Bookmark Dim appttype As Variant appttype = DLookup("", "tblws", " = " & Str(Me!)) DoCmd.OpenForm "frmWS", , , "=" & Me!
4
13182
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying to login (obviously it's using ASPNETDB.mdf). Any ideas? Server Error in '/' Application. --------------------------------------------------------------------------------
1
45165
by: Ron | last post by:
Hi, I had a stored procedure on SQL 2000 server to run calculation with large amount of data. When I called this stored procedure via System.Data.SqlClient.SqlCommand on production, i got error as: (i tried to run the stored procedure on query analyzer, and it works well) Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred...
3
7596
by: Sems | last post by:
Hi I'm using the Session_End event in the global.asax to detect if a users sessions has ended. Is there any way to tell if the session end is due to it being expired and not abandoned? I'm trying to show the user a popup if their session has expired due to a timeout. Whats the best way to do this?
1
5166
by: Scorpion657 | last post by:
Hey I really need help. I have a Website coded using ASP.NET and VB and for some reason, i'm getting the following error when I try to upload or access a large file which is stored in the database. It was working fine when I was runing the site on the localhost. I added the following line to the web.config file to increase the timeout: <httpRuntime maxRequestLength="1048576" executionTimeout="3600"/> I also added: connection timeout =...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.