解决MSSQL下“不能在手动或分布事务方式下创建新的连接”的问题
作者:Juven 来源:织梦幻影 发布时间:2008-07-15 12:48:00
标签:mssql,错误,sql
相信在使用MSSQL数据库下使用事务回滚方式操作多表记录的时候,会经常出现“不能在手动或分布事务方式下创建新的连接”的出错提示信息,这个问题也已困扰我多年。
这次在开发一个大型的商务平台的时候,涉及到数据的计算,同时也必须要多表更新(或删除)。借助GOOGLE也没找到一个真能解决的问题。以前收集过一个MSDN的说明,官方的提示必须,只有用SQL语句执行数据库操作才能使用事务处理。
从官方提示上理解,事式处理中涉及到查询(Select)时,会出现这种出错提示。同时也应该与记录指针(Cursors)有关联。试着这样的思路,将事务处理中原出现的Conn.Execute("select ... from ...")修改为使用rs.Open...命令打开记录集,问题解决。
解决的方法只涉及到Juven的理解,并无权威确认!
MSDN说明:
Tips for Working with Cursors
Some providers, such as SQL Server, implement a forward-scrolling, read-only (or 'firehose') cursor mode, meaning that they can efficiently retrieve data by keeping a connection open. When working with such providers, the connection could be blocked by another user's transaction. The following examples demonstrate scenarios
that result in errors.
dbConn.Open "DSN=SQLForum;UID=sa;PWD=;"
'Example 1
dbConn.BeginTrans
RS.Open "Select * FROM Message", dbConn
Set dbCmd.ActiveConnection = dbConn
Example 1: The problem is that the command object's ActiveConnection is being set to a connection that is forward-scrolling and in 'firehose' mode. This is the same connection involved in the batch mode. The error from the provider will only appear in the Err object, and it will return as unspecified. For example, with the ODBC
Provider, you will get "Unspecified error".
dbConn.Open "DSN=SQLForum;UID=sa;PWD=;"
'Example 2
RS.Open "Select * FROM Message", dbConn
dbConn.BeginTrans
Example 2: The problem here is that the connection is forward-scrolling and in firehose mode, so it cannot be put into transaction mode. The error returned in the Errors collection from the provider will indicate that it is operating in firehose mode, and can't work in transaction mode. For example, with the ODBC Provider against
Microsoft SQL Server, you will get the error "Cannot start transaction while in firehose mode".
dbConn.Open "DSN=SQLForum;UID=sa;PWD=;"
'Example 3
RS.Open "Select * FROM Message", dbConn
Set dbCmd.ActiveConnection = dbConn
dbConn.BeginTrans
Example 3: The problem here is that the connection is in forward-scrolling firehose mode, so it cannot also be involved in a batch mode. The error returned in the Errors collection from the provider will indicate that the transaction could not be started. For example, with the ODBC Provider against Microsoft SQL Server, you will get the error "Cannot start transaction because more than one hdbc is in use".
0
投稿
猜你喜欢
- Web Standards Solutions The Markup and Style Handbook - Chapter 1 清单首发
- 如果您是HTML的初学者,请您先自学HTML。因为DHTML是现有的HTML技术的一个综合,所以HTML语言对学习动态HTML是
- 优雅的设计经常包含一些特殊的字体,而这些字体并不存在于用户的字体库中,我们并不能奢求每一个访客都是设计师。 :-)虽然CSS3标
- 很多人可能发现,无论是在sql 2000, 还是在 sql 2005 中,都没有提供字符串的聚合函数, 所以, 当我们在处理下列要求时,会比
- Ewebeditor及fckeditork,90%的网站都是采用这两种编辑器作为产品或者内容的说明部分的编辑窗口,近日,一客户的外贸站点基本
- 本文通过实例解析了 SQL Server 数据库扩展存储过程,实现远程备份与恢复的方法和步骤实例说明: 环境:win2k+sqlserver
- CREATE OR REPLACE PROCEDURE PROC6338196642095312503719(输入新闻主题 Varchar2
- 以下是menu.asp代码 程序代码 <% '-----------------------------------
- 在给blog加上无刷新搜索和即时验证检测后,又看了下代码,感觉太过麻烦,就把XMLHttpRequest请求封装到一个类里面,用起来方便多了
- 使用 Microsoft® SQL Server™ 2000,可以选择在一台计算机上安装 SQL Ser
- 一.权限表mysql数据库中的3个权限表:user 、db、 host权限表的存取过程是:1)先从user表中的host、 user、 pa
- 利用 CSS 来实现对象的垂直居中有许多不同的方法,比较难的是选择那个正确的方法。我下面说明一下我看到的好的方法和怎么来创建一个好的居中网站
- table估计每个跟web打过交道的人都会经常接触到,跟js结合能做出很多不错的体验。这里打算结合js做一个系列,包括一些操作和效果,虽然现
- 2008年的圣诞节LOGO依旧延续着2007年的圣诞老人、鹿车、红帽子、圣诞树、蜡烛等元素装点。当然,也少不了雪花,但在LOGO设计上,较0
- ps:不曾想还有那么好用的方法。汗一个先。Div即父容器不根据内容自适应高度,我们看下面的代码:<div id="main&
- 如何在一个广告旗帜里轮番显示时间长度不一的不同广告?好了,下面就是Ad Rotator组件完整的应用例子:adrot.asp<html
- 为了组织search线的设计师交流会,特地去准备了一些资料。《SERP 2010》是其中一个,但是由于时间关系没有进行讨论。原著是英文报告,
- 简介如果你经常网上冲浪,这样参差不齐的多栏布局,是不是很眼熟啊?类似的布局,似乎一夜之间出现在国内外大大小小的网站上,比如 Pinteres
- 最近做的一个B/S项目,在打印时采用了在IE中嵌入.net winform控件和XML结合的方式(参见http://www.yesky.co
- 对大家推荐很好使用的MySql节点系统,像让大家对MySql节点系统有所了解,然后对MySql节点系统全面讲解介绍,希望对大家有用在向大家详