Solved

ADODB Timout on EXECUTE for MSSQL 2000 Database

Posted on 2007-03-27
16
216 Views
Last Modified: 2013-11-25
Can anyone tell me why this times out?  It's running against a MSSQL server 2000 server.

option explicit

dim cnn, rs
dim sQry, sSqlIns

Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

Cnn.Open "Provider=sqloledb;Data Source=10.20.112.186;Network Library=DBMSSOCN;Initial Catalog=UAT;User ID=sa;Password=xxx;"
cnn.execute "insert into UAT21.STORERCONFIG(STORERKEY,STORERCONFIGKEY,DESCRIPTION,FLAG) VALUES('001','ALDUPIDSTO','IF TURNED ON WILL ALLOW DUPLICATE IDS DURING GEO RECEIPTS','N')"
0
Comment
Question by:kensklein
[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
16 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18804000
>>Can anyone tell me why this times out? <<
Because the INSERT query is taking longer than the default 30 seconds.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18804019
If you feel you have optimized the query, your hardware and network as much as possible, than you will have to resort to increasing the timeout, as in:

dim cnn, rs
dim sQry, sSqlIns

Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

Cnn.Open "Provider=sqloledb;Data Source=10.20.112.186;Network Library=DBMSSOCN;Initial Catalog=UAT;User ID=sa;Password=xxx;"
cnn.CommandTimeout = 300           ' 5 minutes.
cnn.execute "insert into UAT21.STORERCONFIG(STORERKEY,STORERCONFIGKEY,DESCRIPTION,FLAG) VALUES('001','ALDUPIDSTO','IF TURNED ON WILL ALLOW DUPLICATE IDS DURING GEO RECEIPTS','N')"
0
 

Author Comment

by:kensklein
ID: 18804053
You may want to look at the query again.  It's a simple insert of one value.  There is nothing to optimize.  I can run the same query directly in the database and it inserts just fine in less than a second.  As for the connection, I can use the same connection to run a select and it returns just fine, so I don't think it is an issue with the connection object.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:kensklein
ID: 18804080
I should have also noted, that I've increased the timeout more than enough to feel it's something else.  I guess you are essentually correct that it's "timing out", perhaps my question should be what do you think is causing it to timeout.  I was thinking that it may have something to do with the schema being specified in the insert and ADODB not liking that.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18804140
Than I am afraid I have no idea.
0
 

Author Comment

by:kensklein
ID: 18804163
No worries.  Thanks for trying...Ken
0
 
LVL 42

Expert Comment

by:dqmq
ID: 18804535
Perhaps try declaring your connection type at compile time:

dim cnn as ADODB.Connection
set cnn = new ADODB.Connection
Cnn.Open "Provider=sqloledb;Data Source=10.20.112.186;Network Library=DBMSSOCN;Initial Catalog=UAT;User ID=sa;Password=xxx;"
cnn.
cnn.execute "insert into UAT21.STORERCONFIG(STORERKEY,STORERCONFIGKEY,DESCRIPTION,FLAG) VALUES('001','ALDUPIDSTO','IF TURNED ON WILL ALLOW DUPLICATE IDS DURING GEO RECEIPTS','N')"

   
0
 

Author Comment

by:kensklein
ID: 18805123
Maybe that's part of the problem.  This is just vbscript running in windows scripting host.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18805359
Than the following is not an option:
dim cnn as ADODB.Connection
set cnn = new ADODB.Connection
0
 

Author Comment

by:kensklein
ID: 18805423
Good point, but the syntax is actually:

Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

I think dqmq retyped the other syntax in their suggestion.  

My connection is good.  Any recordsets come back fine.  It's just inserts that fail.
0
 
LVL 18

Expert Comment

by:chrismc
ID: 18806155
Is there a trigger on that table? If the command works fine then that should be academic - but who know?

What environment are developing/running in? I guess the main difference between running it in SQL and in you development environment is probably the data drivers. What version of ADO are you running?

You also mention about the "Schema", but in SQL 2000 the schema was actually the "Owner", it didn't become the schema until SQL 2005. Again, I doubt that's the problem but might be worth mentioning.

Cheers
Chris
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 500 total points
ID: 18807092
1. are you sure insert take long time to perform?
2. do you have any error come back?
3 .does it get update?

may try using this

Cnn.Open "Provider=sqloledb;Data Source=10.20.112.186,1433;Network Library=DBMSSOCN;Initial Catalog=UAT;User ID=sa;Password=xxx"
0
 

Author Comment

by:kensklein
ID: 18807819
Thanks Everyone.  EddyKt hit the problem.  When I put the port into the connect string, it worked fine.  Why a select would work without the port, but an update willl not is something interesting.  I guess when the rs object wraps the cnn, it provides some defaults that are not in the cnn object.

Thank you everyone!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18809870
>>Good point, but the syntax is actually: <<
The syntax dqmq was using was for early binding using Visual Basic, since you are using VBScript that is not an option.

>>Why a select would work without the port, but an update willl not is something interesting. <<
Than it is a network problem and specifically can be solved with the Client Network Utility.

>>I guess when the rs object wraps the cnn, it provides some defaults that are not in the cnn object.<<
Not sure what a recordset has got to do with this.  There is no recordset involved in an Insert statement.
0
 

Author Comment

by:kensklein
ID: 18813091
>> >>I guess when the rs object wraps the cnn, it provides some defaults that are not in the cnn object.<<
>> Not sure what a recordset has got to do with this.  There is no recordset involved in an Insert statement.

The reason it is relevant is because in a prior post, network was ruled out because a recordset was returned.  The thought was that if the connect string worked for a recordset, it must work with a cnn.execute also.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18813147
>>The thought was that if the connect string worked for a recordset, it must work with a cnn.execute also. <<
I guess you have put that myth to rest now, then.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how the fundamental information of how to create a table.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

707 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