How can I make my SQL Server CE connection open faster?

此生再无相见时 提交于 2019-12-12 03:14:20

问题


I need some help, I have a SQL Server CE database in my project and I open the connection when loading the first form and keep it open, you know the usual:

if (con.State == ConnectionState.Closed)
{
    con.Open();
}

It works perfectly fine, but that first moment when it's opening the connection is toooooo long.

My question is, isn't there a way to make that opening process go a little faster so that my program's users won't fall asleep waiting for it to open?

Thanks in advance...


回答1:


A given API may have a bunch of overloads on an open command but what's happening underneath is pretty much the same. Unless you switch to a completely different API or another db there is no way to "speed" up the process.

The only thing you can do is to mitigate the issue by moving the opening of the connection to some other part of the application's life-cycle where the user might not notice or mind a delay.

One trick that is widely used is to implement this slight-of-hand is to do your initialization while a splash screen is being displayed to the user. The splash screen might have some fancy graphics and text to "entertain" the end user. You will even see the splash screen updated with what the app is doing at that particular time. Not terribly useful but might be entertaining enough to the user to distract from the delay.

I did this once when users were complaining of an initialization step taking too long. After I published the change the end users swore that the app performed much better. It didn't really. I only manipulated perception.




回答2:


There are a number of reasons, why opening a SQL Compact connection can be extra slow:

1: The database has been created on another platform (For example Windows 7 => Windows XP)

2: The ACL (Access Control List) on the RSA folder is corrupt

3: Invalid Internet Proxy configuration

I have much more details and suggestions for workaround in my blog post here: http://erikej.blogspot.dk/2013/08/faq-why-is-opening-my-sql-server.html



来源:https://stackoverflow.com/questions/29400121/how-can-i-make-my-sql-server-ce-connection-open-faster

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!