RE:无事务查询的事务错误 [英] RE: Transaction Error on None-Transaction Query

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

问题描述

你好彼得,


我曾经遇到过相同的错误ExecuteReader需要命令才能确定连接分配时是否有
有交易?运行两个线程

与数据库交谈。如果我使用单线程或

两个单独的进程没有问题。这两个线程使用相同的连接

字符串,但具有不同的连接实例。 Peter,当你收到

错误信息时,请你检查一下这个过程的主题列表

(Debug-> Window-> Threads)?是否有第二个线程运行这段

代码?


在此期间,我正在尝试重现我身边的症状。然而,

我被这些代码所困:


尝试

{

myTrans =

connection.BeginTransaction(IsolatedLevel.ReadUnc ommitted);

myTrans.Commit();

}

catch {}


为什么在创建交易后立即提交交易?如果

我们在da.Fill(ds)之后提交交易怎么办?


问候,

贾良良(ji ** ** @ online.microsoft.com,删除''在线。'')

Microsoft在线社区支持


让我们的客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


========================================== ========

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。


注意:MSDN托管新闻组支持服务是针对非紧急问题

如果社区或微软支持人员在1个工作日内做出初步回复是可以接受的。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========

此帖子按原样提供。没有保证,也没有授予任何权利。

Hello Peter,

I once came across the same error "ExecuteReader requires the command to
have a transaction when the connection assigned? with running two threads
talking with the database. There was no problem if I use single thread or
two separate processes. These two threads are using the same connection
string, but with different connection instances. Peter, when you get the
error message, would you please check the thread list of the process
(Debug->Window->Threads)? Is there the second thread running this piece of
code?

In the meantime, I am trying the reproduce the symptom on my side. However,
I''m stuck by these lines of code:

try
{
myTrans =
connection.BeginTransaction(IsolationLevel.ReadUnc ommitted);
myTrans.Commit();
}
catch { }

Why do you commit the transaction immediately after it''s created? What if
we commit the transaction after da.Fill(ds)?

Regards,
Jialiang Ge (ji****@online.microsoft.com, remove ''online.'')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

推荐答案

是的,还有其他线程正在运行这段代码。我认为那是'

问题,因为如果我在我的机器上运行它只有一个线程

运行我从来没有得到这个错误。


这里是简化的伪代码:


1)创建数据库连接

2)打开连接

3)读取数据库

4)为从数据库读取的每条记录创建一个线程,并将相同的

连接对象传递到每个线程中

内线:

运行Crystal Reports(Crystal Reports创建自己的

连接)

通过电子邮件发送消息

更新数据库

5)睡眠

6)转到步骤#3

我创建的事务在创建后立即提交允许

''脏读'或未读的读取,如果我不是那么我就会出现记录锁定错误。

"Jialiang Ge [MSFT] "" < ji **** @ online.microsoft.com写信息

新闻:TN ************** @ TK2MSFTNGHUB02.phx.gbl ...
Yes there are other threads running this piece of code. I think that''s the
problem because if I run it on my machine where there is only one thread
running I never get this error.

Here''s simplified pseudo code:

1) Create database connection
2) Open connection
3) Read database
4) Create a thread for each record read from the database and pass the same
connection object into each Thread
Inside the thread:
Run a Crystal Reports (Crystal Reports creates its own
connection)
Email a message
Update database
5) Sleep
6) Go to step #3
I have the transaction commited immediately after it''s created to allow
''dirty reads'' or uncommited reads, if I don''t then I get record lock errors.
""Jialiang Ge [MSFT]"" <ji****@online.microsoft.comwrote in message
news:TN**************@TK2MSFTNGHUB02.phx.gbl...

你好彼得,


我曾遇到同样的错误ExecuteReader需要命令
$ b连接分配时,$ b有一个事务?运行两个线程

与数据库交谈。如果我使用单线程或

两个单独的进程没有问题。这两个线程使用相同的连接

字符串,但具有不同的连接实例。 Peter,当你收到

错误信息时,请你检查一下这个过程的主题列表

(Debug-> Window-> Threads)?是否有第二个线程运行这段

代码?


在此期间,我正在尝试重现我身边的症状。

然而,

我被这些代码所困:


尝试

{

myTrans =

connection.BeginTransaction(IsolatedLevel.ReadUnc ommitted);

myTrans.Commit();

}

catch {}


为什么在创建交易后立即提交交易?如果

我们在da.Fill(ds)之后提交交易怎么办?


问候,

贾良良(ji ** ** @ online.microsoft.com,删除''在线。'')

Microsoft在线社区支持


让我们的客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


========================================== ========

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。


注意:MSDN托管新闻组支持服务是针对非紧急问题

如果社区或微软支持人员在1个工作日内做出初步回复是可以接受的。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========

此帖子按原样提供。没有保证,也没有赋予

权利。
Hello Peter,

I once came across the same error "ExecuteReader requires the command to
have a transaction when the connection assigned? with running two threads
talking with the database. There was no problem if I use single thread or
two separate processes. These two threads are using the same connection
string, but with different connection instances. Peter, when you get the
error message, would you please check the thread list of the process
(Debug->Window->Threads)? Is there the second thread running this piece of
code?

In the meantime, I am trying the reproduce the symptom on my side.
However,
I''m stuck by these lines of code:

try
{
myTrans =
connection.BeginTransaction(IsolationLevel.ReadUnc ommitted);
myTrans.Commit();
}
catch { }

Why do you commit the transaction immediately after it''s created? What if
we commit the transaction after da.Fill(ds)?

Regards,
Jialiang Ge (ji****@online.microsoft.com, remove ''online.'')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.



Hello Peter,

问题的快速解决方法可以是锁定这个代码来代码
代码,这样线程就不会同时运行它。例如:
http: //msdn.microsoft.com/en-us/libr...cz(VS.71).aspx


我还在研究其原因多个线程运行时出错

并发。我会尽快回来。


问候,

Jialiang Ge(ji****@online.microsoft.com,删除''在线。'')

Microsoft在线社区支持


====================== ===========================

让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


此帖子按原样提供。没有保证,也没有授予任何权利。

================================= ================

Hello Peter,

A quick resolution of the problem can be to have a lock around this piece
of code so that threads will not run it simultaneously. For example:
http://msdn.microsoft.com/en-us/libr...cz(VS.71).aspx

I''m still researching the reason of the error when multiple threads run it
concurrently. I will be back as soon as possible.

Regards,
Jialiang Ge (ji****@online.microsoft.com, remove ''online.'')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================


你好彼得,


快速解决问题的方法就是锁定这段代码,以便线程不会同时运行它。例如:
http: //msdn.microsoft.com/en-us/libr...cz(VS.71).aspx


我还在研究其原因多个线程运行时出错

并发。我会尽快回来。


问候,

Jialiang Ge(ji****@online.microsoft.com,删除''在线。'')

Microsoft在线社区支持


====================== ===========================

让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


此帖子按原样提供。没有保证,也没有授予任何权利。

================================= ================

Hello Peter,

A quick resolution of the problem can be to have a lock around this piece
of code so that threads will not run it simultaneously. For example:
http://msdn.microsoft.com/en-us/libr...cz(VS.71).aspx

I''m still researching the reason of the error when multiple threads run it
concurrently. I will be back as soon as possible.

Regards,
Jialiang Ge (ji****@online.microsoft.com, remove ''online.'')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================


这篇关于RE:无事务查询的事务错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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