访问多个SQL Server的最佳实践 [英] Best practice to access multiple SQL server

查看:97
本文介绍了访问多个SQL Server的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我打算构建一个asp.net Web应用程序,一个可以连接到多个sql server数据库的仪表板。



目前我的网站上运行的是一个系统,需要有一个仪表板才能看到每个站点。



保持每个站点连接字符串旁边的最佳做法是什么?





谢谢



我尝试过:



使用多个sql连接字符串并将每个站点的sql server凭证保存到数据库

系统将使用其连接每个站点自己的sql server连接字符串

Hi all,

i am intending to build an asp.net web application, a dashboard which can connect to multiple sql server database.

Currently i have a system running in our sites, and need to have a dashboard to have visibility to each site.

What is the best practice beside to keep each sites connect string?


Thank you

What I have tried:

using many sql connection string and save each site sql server credential to a database
System will connect each sites using its own sql server connection string

推荐答案

通常在SQL命令完成后,连接关闭。

因为SQL Server使用连接池,重新打开连接非常快。

所以我认为最好在完成后关闭连接。

Usually after an SQL command has completed, the connection is closed.
As SQL Server uses connection pooling, reopening a connection is very quick.
So I think it's best practice to close the connection when you are done.
引用:

我们建议您在使用完毕后始终关闭连接,以便可以将连接返回到池中。

We recommend that you always close the connection when you are finished using it, so that the connection can be returned to the pool.

建立连接| Microsoft Docs [ ^ ]



此处有更多信息: SQL Server连接池(ADO.NET)| Microsoft Docs [ ^ ]


这篇关于访问多个SQL Server的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆