本地数据库第一次运行超时异常

发布于 2024-09-10 05:02:47 字数 399 浏览 1 评论 0原文

我的连接字符串如下所示。我第一次运行该应用程序时显示“超时异常”。不过,对于接下来的运行来说,还是没问题的。我认为,将数据库附加到 SQLExpress 服务器可能需要一些时间。有没有办法增加超时时间?谢谢

,我正在使用 SQLServer 2005 Express、VS 2008 和 .Net 3.5。

<add name="dotnetConnectionString" connectionString="Server=.\SQLExpress;AttachDbFilename=|DataDirectory|dotnet.mdf; Database=dotnet;Trusted_Connection=Yes;" providerName="System.Data.SqlClient"/>  

My connection string is like the following. It shows 'Timeout Exception' first time I run the application. But, for the subsequent run, it's ok. I think, it might take some time to attach the DB to the SQLExpress Server. Is there anyway to increase Timeout period? Thanks

I am using SQLServer 2005 Express and VS 2008 and .Net 3.5.

<add name="dotnetConnectionString" connectionString="Server=.\SQLExpress;AttachDbFilename=|DataDirectory|dotnet.mdf; Database=dotnet;Trusted_Connection=Yes;" providerName="System.Data.SqlClient"/>  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

疑心病 2024-09-17 05:02:47

在连接字符串中使用“连接超时”并指定秒数。首先尝试 60。

Use Connection Timeout in your connection string and specify the number of seconds. Try 60 at first.

毁梦 2024-09-17 05:02:47

这在较慢的机器上是正常的。在我的本地数据库中,我在使用数据库之前运行一个批处理文件,使用以下命令:

@"\SqlLocalDB.exe" create -s

example:
@“C:\ Program Files \ Microsoft SQL Server \ 110 \ Tools \ Binn \ SqlLocalDB.exe”创建v11.0 -s

This is normal on slower machines. In my local db, I run a batch file before using the database, with the following command:

@"\SqlLocalDB.exe" create -s

example:
@"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe" create v11.0 -s

夜唯美灬不弃 2024-09-17 05:02:47

https://www.connectionstrings.com/sql-server-2012/

阅读此内容部分:
'与 LocalDB 的第一次连接将创建并启动实例,这需要一些时间,并可能导致连接超时失败。如果发生这种情况,请稍等一下,然后再次连接。

https://www.connectionstrings.com/sql-server-2012/

Read this part:
'The first connection to LocalDB will create and start the instance, this takes some time and might cause a connection timeout failure. If this happens, wait a bit and connect again.'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文