Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to make a ms sql connection faster in vb6

Posted on 2016-11-23
13
Medium Priority
?
56 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
  • 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 49

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 35

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 35

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 35

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 35

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 35

Assisted Solution

by:Pawan Kumar
Pawan Kumar earned 2000 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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

824 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