Slow first connection to SQL server in VB.NET
Posted on 2005-04-11
I have a form with a textbox and listbox on it, it is designed for the user to enter name then press enter and it will display records that match.
sqlClient.SelectCommand.CommandText = "SELECT ClientID, Name FROM tblClient WHERE Name LIKE '%" & Replace(replace(txtSearch.Text,"'","''"), " ", "%") & "%'"
The wierd thing is that the first time this is run it takes about 10-15 seconds to come back with the results, then for every other attempt while the program is open it is lightning just under the 1sec mark (which is more like it), if you shut the program down and try it again it will be slow for that first attempt again.
I have tried to trick the SQL connection by when the program starts up I get it to
txtSQLVersion.Text = SQL.sqlBMS.ServerVersion()
I thought that at least then the user waits 10 seconds while the program loads instead of the first time they go to access a this search window.