Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
Good Day!

I need to know what is the Best, The Most Efficient and The Fastest way to connect MS SQL SERVER 2014 Database using VB.NET 2015

I am also working in this combination but the problem is that when is execute a query directly in the SQL Server Query Editor it retrieves the the data that is consisted of almost 10,000 rows in just 1-2 seconds.
But when i execute the same query in VB.NET application and fill the datagridview it consumes 30-40 seconds that means the 20 times slower that the actual retrieval time of the query.

Please anyone can help me to figure it out what the mistake is in fact.

Thanks
Muhammad Asim Mughal

What I have tried:

I Need A General Solution without sharing the code specifically.
Posted
Updated 27-Nov-17 0:38am
Comments
CHill60 27-Nov-17 6:35am    
It would help if we could see your connection string (remove any sensitive information first) and exactly how you are populating your datagridview. Use the Improve Question link to add this information to your post
Muhammad Asim Mughal 27-Nov-17 8:57am    
Sir,
Thanks for giving your time.
My actual question is that if the natural time of a query is 2 seconds then why it takes 40 seconds when it is called in VB.NET Application to fill the data in a DataGridView ?
CHill60 27-Nov-17 11:25am    
It depends on
a) How you connected to the database
b) How you are populating your DataGridView
There is no one single answer to your question

1 solution

Generally you should not query a lot of rows, you should page the results for performance reasons.

The DataGridView has a lot of overhead for displaying rows, your actual query results should take the 2 secs you mentioned (if it is done on your client machine, if not then you also have the network overhead to consider).

If the query on SQL Server takes 2 secs for 10,000 rows then you should look into indexing your query properly (it should be faster I presume but can not be sure since I don't know the details of your query schema, tables and columns used).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900