Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection Time out error while connection VB6 to SQL Server 2008 1

Status
Not open for further replies.
Jul 23, 2009
16
US
I am using Visual Basic 6 as the front end
I am using SQL server 2008 express as the back end
I am trying to connect to a table in SQL server in MODEL database which has about 140 million records. Table name is dbo.tickdata_master
I am using ADO
Whenever I am trying to fetch records from that table, I get a
"Timeout expired" -2147217871 error

How do I resolve this and see that I do not get this error
When I am trying to connect to other tables using the same connection, which have just 100 rows, I am not getting this error and I am able to fetch all the data with no problem
The code is attached
I tried using Connectiontimeout = 0, but it did not work for the large table

Please suggest me a remedy, so that I can fetch rows even from table of about 140 million row





Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
dim str as string
str = "select count(*) from dbo.tickdata_master"

cn.ConnectionTimeout = 0
cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=JACKIE\SQLEXPRESS;Use Procedure for Prepare= 1;Auto Translate=True;Packet Size=4096;Workstation ID=JACKIE;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=model"

rs.Open str, cn

 
I think you want to use the CommandTimeout.

ConnectionTimeout is used to connect to the server. CommandTimeout is used for the command you send it (like Select.....)




-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
The problem is going to be that it takes more than the default timeout of 30 seconds to count all the rows in that table. You need to adjust the timeout as George said.

Why do you have tables in the Model database? That's a system database which shouldn't have any data in it as it's the template which is used when creating new databases so any data in it will be places in any new databases you create.

Denny
MVP
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / SQL 2005 BI / SQL 2008 DBA / SQL 2008 DBD / SQL 2008 BI / MWSS 3.0: Configuration / MOSS 2007: Configuration)
MCITP (SQL 2005 DBA / SQL 2008 DBA / SQL 2005 DBD / SQL 2008 DBD / SQL 2005 BI / SQL 2008 BI)

My Blog
 
gmmastros

Thanks a bunch for your valuable suggestion
That was quite helpful
Have a good day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top