How to make a ms sql connection faster in vb6

We have a datagrid that it takes time to always load (see code below).  We have the same open in other apps and it's not slow.

Please advice
rayluvsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rayluvsConnect With a Mentor Author Commented:
Yes, it es the server name.  We had "(local)" and change it to the actual server name, and it worked fast.

Why is it that if you use "(local)" as a server name it takes longer to connect than when entering the actual "server" name?
0
 
rayluvsAuthor Commented:
ooops!  (forgot the code)...

 Set cnn = Nothing
 Set rst = Nothing
 Set cnn = New ADODB.Connection
 Set rst = New ADODB.Recordset

 cnn.Open "Provider=SQLOLEDB; " & _
          "Initial Catalog=" & cdb & "; " & _
          "Data Source=" & srvname  & "; " & 
          "integrated security=SSPI; persist security info=True;"

 sSql= "select col1, col2, col3 from TableName"
 dcRecs.ConnectionString = cnn
 dcRecs.RecordSource = sSql
 dcRecs.Refresh

Open in new window

0
 
Martin LissOlder than dirtCommented:
I don't know if this MS article helps but it's all I can offer.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
rayluvsAuthor Commented:
Hi.  We read it but don't know what you want us to look for or anything that points to slow connection.  Can you be more specific?
0
 
Pawan KumarDatabase ExpertCommented:
How much time it is taking to connect , > 

How much time your SQL query is taking , >
0
 
rayluvsAuthor Commented:
The VB6 code takes around 8 to 12 seconds to load the datagrid window.

Running the same script in MS sql studio takes less than a second.

We have another apps that has the same cnn.Open and it takes 1 second.

(we still checking whats going on... hope u can help)
0
 
Pawan KumarDatabase ExpertCommented:
How many rows are we getting ?

Also are we getting the same exact data in this app and the other apps?
0
 
rayluvsAuthor Commented:
Yes, accessing same tables; rows can be 1 or 10000.
0
 
Pawan KumarDatabase ExpertCommented:
Any update this ?
0
 
Pawan KumarDatabase ExpertCommented:
Great !!
0
 
rayluvsAuthor Commented:
Thanx, but can you explain why using "(local)" as a server name it takes longer to connect than when entering the actual "server" name?
0
 
Pawan KumarConnect With a Mentor Database ExpertCommented:
If you put local then the System will have to find out the name of the local server out of the servers available. If you directly put the name then this  time will be saved.
0
 
rayluvsAuthor Commented:
Thanx!  Selected our entry as the solution since it solved our problem.

Thanx again!
0
All Courses

From novice to tech pro — start learning today.