关于sql的connection, 怎么做更好?

group333 2009-02-09 12:24:23
我正在做一个考试程序(vb.net) C/S结构,有一台Sql server 2000服务器 正式投入使用后将有500个用户同时在线.我的问题

第一个问题: 关于数据连接,哪种方法更好
1) 客户端程序的connection是在需要访问数据时才打开,用完后马上关闭 (这样connection.close 或connection.open将比较频繁)
2) 客户端程序的connection.open后,一直处于打开状态,直到本软件退出.

不知哪种方法对服务器的压力是最大的

第二个问题: Sql Server服务器的硬件服务需要多高.
目前暂定 1G内存 CPU:2G
...全文
214 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
mx2001 2009-02-13
  • 打赏
  • 举报
回复
1. using , end using 用一次,开关一次。不可以一直开着
2. 服务器如果没有其他过多的进程,只是跑sql server 2000,500个用户一般可以,建议把内存上2G。客户端注意代码质量。
Yangbin990 2009-02-10
  • 打赏
  • 举报
回复
as long as you make sure your connetion string text is exactly same, you should always open and close that immediately. Because connection pool will manage to assign the connection to next request.

The close command is actrually not really close the connection, it just allow the connection can be used by next request. The connection is still open and keep in connection pool.

if you don't close that, for example 10 users log in and keep the connection open, then the 11th user cannot build a new connection.

If you always close the connection, then 10 connection can serve 20, or 30 users because then are not really connect to SQL as same moment.
groundsky 2009-02-10
  • 打赏
  • 举报
回复
使用sqladapter 它填充数据后会自动关闭,不用主动去关闭连接
supremeholy 2009-02-10
  • 打赏
  • 举报
回复
默认是使用数据库连接池的,用完后Close,这样可以将连接放回连接池,不要Dispose掉,这样是释放资源,并没有放回到连接池中。
zxdouzx 2009-02-10
  • 打赏
  • 举报
回复
connection OPEN了 必须得CLOSE的 不用问。。。
king19840811 2009-02-09
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 king19840811 的回复:]
connection打开后马上关闭。不必担心它会影响你的性能。
因为sqlserver有线程池。当你同时打开相同的连接时会使用线程池中的连接
[/Quote]

..晕搞混了。是连接池。。。
JeffrySun 2009-02-09
  • 打赏
  • 举报
回复
客户端程序的connection是在需要访问数据时才打开,用完后马上关闭
龙宜坡 2009-02-09
  • 打赏
  • 举报
回复
第二个问题: Sql Server服务器的硬件服务需要多高.
目前暂定 1G内存 CPU:2G



内存又不值钱,多加几根不行!

如果是用的IBM或DELL等服务器另当别论!
erytbc 2009-02-09
  • 打赏
  • 举报
回复
马上关闭吧
king19840811 2009-02-09
  • 打赏
  • 举报
回复
connection打开后马上关闭。不必担心它会影响你的性能。
因为sqlserver有线程池。当你同时打开相同的连接时会使用线程池中的连接
万小萌 2009-02-09
  • 打赏
  • 举报
回复
connection是在需要访问数据时才打开,用完后马上关闭,必须的!这样connection.close 或connection.open将比较频繁,频繁不代表这里花很多性能代价!
budongling 2009-02-09
  • 打赏
  • 举报
回复
1。用完数据库 必须要及时地关闭。不提倡第2中方法

2。如果是10个左右的用户,你这个应用需求很低的,随便拉个机器就好了。我们单位的70个客户端,还是用的双P3服务期,内存也只有1g。用得挺好的。

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧