重用SqlDataAdapter可以解决问题吗? [英] Reuse the SqlDataAdapter can it couse troubles?

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

问题描述

你好,


我在VB.NET(ASP.NET)中有一个模块,最后我声明了

SqlConnection和SqlDataAdapter。


喜欢:


模块AccessDB

Dim sqlCmd作为新的SqlCommand

Dim conAanvraag As New

SqlConnection(ConfigurationSettings.AppSettings(" C onnectionString"))

Dim daAanvraag As New SqlDataAdapter


In我的模块有一些功能,所有这些功能都使用

sqlDataAdapter。我可以这样使用它还是我必须在每个函数中包含一个新的
sqldataadapter?该方法有效,但我不知道是否

它可能会导致一些问题。


Thnx提前,

Victor

Hello there,

I have a module in VB.NET (ASP.NET) and on top I declare the
SqlConnection and the SqlDataAdapter.

Like:

Module AccessDB
Dim sqlCmd As New SqlCommand
Dim conAanvraag As New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Dim daAanvraag As New SqlDataAdapter

In my Module there are some functions and all those functions use the
sqlDataAdapter. Can i use it in this way OR do i have to include a new
sqldataadapter in every function? The method works but i dont know if
it can cause problems some how.

Thnx in advance,
Victor

推荐答案

只要多个线程没有给这个模块打电话就不会有问题

同时。


" Victor" < 6 **** @ vanhillo.net>在留言中写道

news:d4 ************************** @ posting.google.c om ...
That shouldn''t be a problem as long as multiple threads aren''t making calls
to this module at the same time.

"Victor" <vi****@vanhillo.net> wrote in message
news:d4**************************@posting.google.c om...
你好,

我在VB.NET(ASP.NET)中有一个模块,最后我声明了SqlConnection和SqlDataAdapter。

喜欢:

模块AccessDB
Dim sqlCmd作为新的SqlCommand
Dim conAanvraag As New
SqlConnection(ConfigurationSettings.AppSettings(" C onnectionString")) )
Dim daAanvraag作为新的SqlDataAdapter

在我的模块中有一些函数,所有这些函数都使用
sqlDataAdapter。我可以这样使用它还是我必须在每个函数中包含一个新的
sqldataadapter?该方法有效,但我不知道它是否会引起问题。

Thnx提前,
Victor
Hello there,

I have a module in VB.NET (ASP.NET) and on top I declare the
SqlConnection and the SqlDataAdapter.

Like:

Module AccessDB
Dim sqlCmd As New SqlCommand
Dim conAanvraag As New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Dim daAanvraag As New SqlDataAdapter

In my Module there are some functions and all those functions use the
sqlDataAdapter. Can i use it in this way OR do i have to include a new
sqldataadapter in every function? The method works but i dont know if
it can cause problems some how.

Thnx in advance,
Victor



这不会同时支持两个活跃的Web用户。每个功能都应该有自己的价值。


- 布鲁斯(sqlwork.com)

" Victor" < 6 **** @ vanhillo.net>在留言中写道

news:d4 ************************** @ posting.google.c om ...

|你好,

|

|我在VB.NET(ASP.NET)中有一个模块,在顶部我声明了

| SqlConnection和SqlDataAdapter。

|

|喜欢:

|

|模块AccessDB

| Dim sqlCmd作为新的SqlCommand

| Dim conAanvraag As New

| SqlConnection(ConfigurationSettings.AppSettings(" C onnectionString"))

| Dim daAanvraag作为新的SqlDataAdapter

|

|在我的模块中有一些功能,所有这些功能都使用

| SqlDataAdapter的。我可以这样使用它还是我必须包含一个新的

| sqldataadapter在每个功能?该方法有效,但我不知道是否

|它会引起一些问题。

|

| Thnx提前,

| Victor
this will not support two active web users at once. every function should
have its own.

-- bruce (sqlwork.com)
"Victor" <vi****@vanhillo.net> wrote in message
news:d4**************************@posting.google.c om...
| Hello there,
|
| I have a module in VB.NET (ASP.NET) and on top I declare the
| SqlConnection and the SqlDataAdapter.
|
| Like:
|
| Module AccessDB
| Dim sqlCmd As New SqlCommand
| Dim conAanvraag As New
| SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
| Dim daAanvraag As New SqlDataAdapter
|
| In my Module there are some functions and all those functions use the
| sqlDataAdapter. Can i use it in this way OR do i have to include a new
| sqldataadapter in every function? The method works but i dont know if
| it can cause problems some how.
|
| Thnx in advance,
| Victor


你好Victor,


我在我的业务对象中做这种事情并且效果很好。但是,作为

,Marina指出你不想在全球范围内做到这一点,而是绑定到一个

操作,它的作用是当前的线程。例如,在我的情况下,

重用DA的业务对象我知道单个实例不是从多个线程访问的
所以这是安全的,但是通过将数据适配器绑定到Application对象或静态

来做同样的事情(在ASP.NET的情况下,任何东西都超过了单个

请求基本上是因为每个请求都可以在不同的

线程上运行。


+++ Rick ---


-


Rick Strahl

West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/

----------------------------------

制造波浪在网上

" Victor" < 6 **** @ vanhillo.net>在留言中写道

news:d4 ************************** @ posting.google.c om ...
Hi Victor,

I do this sort of thing in my business objects and it works well. But as
Marina points out you don''t want to do this globally but tied to an
operation that''s scoped to the current thread. For example, in my case of
the business object reusing the DA I know that a single instance is not
accessed from more than a single thread and so this is safe, but doing the
same thing by tying the data adapter to an Application object or a static
would not be (in the case of ASP.NET anything that spans more than a single
request basically since every request can potentially run on a different
thread).

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
----------------------------------
Making waves on the Web
"Victor" <vi****@vanhillo.net> wrote in message
news:d4**************************@posting.google.c om...
你好,

我在VB.NET(ASP.NET)中有一个模块,最后我声明了SqlConnection和SqlDataAdapter。

喜欢:

模块AccessDB
Dim sqlCmd作为新的SqlCommand
Dim conAanvraag As New
SqlConnection(ConfigurationSettings.AppSettings(" C onnectionString")) )
Dim daAanvraag作为新的SqlDataAdapter

在我的模块中有一些函数,所有这些函数都使用
sqlDataAdapter。我可以这样使用它还是我必须在每个函数中包含一个新的
sqldataadapter?该方法有效,但我不知道它是否会引起问题。

Thnx提前,
Victor
Hello there,

I have a module in VB.NET (ASP.NET) and on top I declare the
SqlConnection and the SqlDataAdapter.

Like:

Module AccessDB
Dim sqlCmd As New SqlCommand
Dim conAanvraag As New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))
Dim daAanvraag As New SqlDataAdapter

In my Module there are some functions and all those functions use the
sqlDataAdapter. Can i use it in this way OR do i have to include a new
sqldataadapter in every function? The method works but i dont know if
it can cause problems some how.

Thnx in advance,
Victor



这篇关于重用SqlDataAdapter可以解决问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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