Solved

How to make a ms sql connection faster in vb6

Posted on 2016-11-23
13
43 Views
Last Modified: 2016-11-30
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
0
Comment
Question by:rayluvs
[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
  • 7
  • 5
13 Comments
 

Author Comment

by:rayluvs
ID: 41899948
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
 
LVL 47

Expert Comment

by:Martin Liss
ID: 41899952
I don't know if this MS article helps but it's all I can offer.
0
 

Author Comment

by:rayluvs
ID: 41899958
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
Technology Partners: 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!

 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41899995
How much time it is taking to connect , > 

How much time your SQL query is taking , >
0
 

Author Comment

by:rayluvs
ID: 41900086
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
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41900093
How many rows are we getting ?

Also are we getting the same exact data in this app and the other apps?
0
 

Author Comment

by:rayluvs
ID: 41900489
Yes, accessing same tables; rows can be 1 or 10000.
0
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41901547
Any update this ?
0
 

Accepted Solution

by:
rayluvs earned 0 total points
ID: 41901598
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
 
LVL 28

Expert Comment

by:Pawan Kumar
ID: 41901664
Great !!
0
 

Author Comment

by:rayluvs
ID: 41901722
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
 
LVL 28

Assisted Solution

by:Pawan Kumar
Pawan Kumar earned 500 total points
ID: 41901725
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
 

Author Closing Comment

by:rayluvs
ID: 41907013
Thanx!  Selected our entry as the solution since it solved our problem.

Thanx again!
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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

735 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