如果连接丢失,如何自动重新连接sql连接

编程入门 行业动态 更新时间:2024-10-24 12:28:33
本文介绍了如果连接丢失,如何自动重新连接sql连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在c#win表单项目中有一个sql连接 i如果连接丢失就想重新连接这个.. 怎么办这个 谢谢

I have a sql connection in c# win form project i want to reconnect this if connection is drop.. how to do this thanks

推荐答案

你应该调查的第一件事是连接丢失的原因。如果这是一个可接受且常见的情况,那么我建议使用连接池,以便在每个工作单元之后,程序关闭连接,并在新工作单元开始的地方重新打开。 有关详细信息,请参阅 SQL服务器连接池(ADO.NET) [ ^ ]。 另请注意 ConnectRetryCount 和 ConnectRetryInterval in ConnectionString [ ^ ] The first thing you should investigate is why the connection is lost. If this is an acceptable and 'common' situation then I'd suggest using connection pooling so that after each unit of work the connection is closed by your program and re-opened where a new unit of work is started. For more information, see SQL Server Connection Pooling (ADO.NET)[^]. Also notice both ConnectRetryCount and ConnectRetryInterval in ConnectionString[^]

请尝试以下操作.. 1)自动重新连接MS Sever SQL连接 2)安全保持数据库连接长时间打开 Try the following.. 1) Automatic reconnect MS Sever SQL connection 2) is it safe to keep database connections open for long time

更多推荐

如果连接丢失,如何自动重新连接sql连接

本文发布于:2023-11-05 04:53:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559956.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!