SQLConnection问题 [英] SQLConnection question

查看:64
本文介绍了SQLConnection问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.net项目我做了很多与SQL Server的连接

数据库。我在模块中使用全局变量进行连接声明

(后面的VB.Net代码)


一切正常但是当我从默认页面需要30

秒来显示选择请求的结果


在这30秒内,另一个用户想要打开另一个

来自默认页面的表格,我有一个错误:连接已经

打开


我认为它''因为我全局使用连接变量。


任何想法在ASP.net项目中使用连接对象的最佳方式




-

Ceci est une signature automatique de MesNews。

网站: http://www.mesnews.net

Im my ASP.net project I do a lot of connection to the SQL Server
Database. I use a global variabe for my connection declare in a module
(VB.Net code behind)

All is ok but when I start a form from the default page it takes 30
seconds to show the resultat of a select request

And when, during this 30 seconds, a another user want open a another
forms from the default page, I have an error : "Connection are already
open"

I think it ''s because I use the connection variable globally.

Any idea to use the best way the connection object in a ASP.net project
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net

推荐答案

你为什么不每次都建立一个新的连接?大多数司机已经内置了

连接池。


" bnob"写道:
Why don''t you create a new connection every time? Most driver has built-in
connection pooling already.

"bnob" wrote:
我的ASP.net项目我做了很多与SQL Server
数据库的连接。我在模块中使用全局变量连接声明
(后面的VB.Net代码)

一切正常但是当我从默认页面启动表单时需要30个>秒显示选择请求的结果

当在30秒内,另一个用户想要从默认页面打开另一个
表单时,我有一个错误:连接已经打开了

我认为这是因为我全局使用连接变量。

任何想法都使用连接对象的最佳方式一个ASP.net项目


- Ceci est une signature automatique de MesNews。
网站: http://www.mesnews.net
Im my ASP.net project I do a lot of connection to the SQL Server
Database. I use a global variabe for my connection declare in a module
(VB.Net code behind)

All is ok but when I start a form from the default page it takes 30
seconds to show the resultat of a select request

And when, during this 30 seconds, a another user want open a another
forms from the default page, I have an error : "Connection are already
open"

I think it ''s because I use the connection variable globally.

Any idea to use the best way the connection object in a ASP.net project
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net



是的 - 不要制作共享对象!考虑一下,一个连接为一个

整个应用程序 - 所以当然如果第二个用户尝试使用它而第一个

用户正在使用它,你将会有问题。


因此解决方案是不使用全局连接对象,或者每个用户真正需要的任何对象。


" bnob" < BN ** @ bluewin.ch>在消息中写道

新闻:mn *********************** @ bluewin.ch ...
Yes - don''t make shared objects! Think about it, one connection for an
entire app - so of course if a second user tries to use it while the first
user is using it, you are going to have problems.

So solution is to not use global connection objects, or any object which
really needs to be per user.

"bnob" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
我是我的ASP.net项目我与SQL Server
数据库做了很多连接。我在模块中使用全局变量连接声明
(后面的VB.Net代码)

一切正常但是当我从默认页面启动表单时需要30个>秒显示选择请求的结果

当在30秒内,另一个用户想要从默认页面打开另一个
表单时,我有一个错误:连接已经打开了

我认为这是因为我全局使用连接变量。

任何想法都使用连接对象的最佳方式一个ASP.net项目


- Ceci est une signature automatique de MesNews。
网站: http://www.mesnews.net
Im my ASP.net project I do a lot of connection to the SQL Server
Database. I use a global variabe for my connection declare in a module
(VB.Net code behind)

All is ok but when I start a form from the default page it takes 30
seconds to show the resultat of a select request

And when, during this 30 seconds, a another user want open a another
forms from the default page, I have an error : "Connection are already
open"

I think it ''s because I use the connection variable globally.

Any idea to use the best way the connection object in a ASP.net project
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net



所以解决方案是每次创建一个连接对象并关闭它

请求完成后


我的意思是每个用户的连接对象。


Marina " <所以***** @ nospam.com> écritdansle message de news:

#i ************** @ TK2MSFTNGP12.phx.gbl ...
So the solution is to create a connection object every time and close it
when the request is finished

I mean connections object that are per user.

"Marina" <so*****@nospam.com> a écrit dans le message de news:
#i**************@TK2MSFTNGP12.phx.gbl...
是 - 不要做共享的对象!考虑一下,一个连接整个应用程序 - 所以当然如果第二个用户试图在第一个用户使用它时使用它,你将遇到问题。
<因此,解决方案是不使用全局连接对象,或者每个用户真正需要的任何对象。

bnob < BN ** @ bluewin.ch>在消息中写道
新闻:mn *********************** @ bluewin.ch ...
Yes - don''t make shared objects! Think about it, one connection for an
entire app - so of course if a second user tries to use it while the first
user is using it, you are going to have problems.

So solution is to not use global connection objects, or any object which
really needs to be per user.

"bnob" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
我是我的ASP.net项目我做了很多与SQL Server
数据库的连接。我在模块中使用全局变量连接声明
(后面的VB.Net代码)

一切正常但是当我从默认页面启动表单时需要30个>秒显示选择请求的结果

当在30秒内,另一个用户想要从默认页面打开另一个
表单时,我有一个错误:连接已经打开了

我认为这是因为我全局使用连接变量。

任何想法都使用连接对象的最佳方式一个ASP.net项目


- Ceci est une signature automatique de MesNews。
网站: http://www.mesnews.net
Im my ASP.net project I do a lot of connection to the SQL Server
Database. I use a global variabe for my connection declare in a module
(VB.Net code behind)

All is ok but when I start a form from the default page it takes 30
seconds to show the resultat of a select request

And when, during this 30 seconds, a another user want open a another
forms from the default page, I have an error : "Connection are already
open"

I think it ''s because I use the connection variable globally.

Any idea to use the best way the connection object in a ASP.net project
?

--
Ceci est une signature automatique de MesNews.
Site : http://www.mesnews.net



这篇关于SQLConnection问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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