Solved

How to make a ms sql connection faster in vb6

Posted on 2016-11-23
13
29 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 45

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
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
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 17

Expert Comment

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

Also are we getting the same exact data in this app and the other apps?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

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

Expert Comment

by:Pawan Kumar Khowal
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 17

Expert Comment

by:Pawan Kumar Khowal
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 17

Assisted Solution

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
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…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now