解决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
投稿
猜你喜欢
- 本文环境是python3,采用的是urllib,BeautifulSoup搭建。说下思路,这个项目分为管理器,url管理器,下载器,解析器,
- 前言在Python中已经内置了一个smtp邮件发送模块,Django在此基础上进行了简单地封装,让我们在Django环境中可以更方便更灵活的
- 如何实现自定义一个异常python内置了许多异常类,为编写代码划定红线,才使调试代码时能及时发现错误。那么我们编写一个模块也可以为使用此模块
- // 1.采用计算属性来获取$store中的值computed: { listenstage() {
- Javascript 正常取来源网页的URL只要用: document.referrer就可以了!但,如果来源页是Jav
- 我们在日常开发中,我们经常会面对复杂的子系统,其中包含许多相互关联的类和接口。直接使用这些类和接口可能会导致代码的复杂性增加,使得系统难以维
- 安装Pytorch在pytorch官网上选择相应选项,我的是OS X, pip, python2.7, none CUDA。(之所以用pyt
- 01、Pandas在数据分析师的日常工作中,70%到80%都涉及到理解和清理数据,也就是数据探索和数据挖掘。Pandas主要用于数据分析,这
- 一般情况下,局域网里的终端比如本地服务器设置静态IP的好处是可以有效减少网络连接时间,原因是过程中省略了每次联网后从DHCP服务器获取IP地
- mysql时间戳转换select unix_timestamp(); 获取当前时间的时间戳SELECT FROM_UNIXTIME(1529
- 这篇文章主要介绍了python线程join方法原理解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋
- 详解Python中的三元运算什么是三元运算符在大部分编程语言中都有三目运算,也称三元运算,Python语言从Python2.5版本开始也引入
- 作为python和机器学习的初学者,目睹了AI玩游戏的各种风骚操作,心里也是跃跃欲试。然后发现微信跳一跳很符合需求,因为它不需要处理连续画面
- 上一篇已经介绍了celery的基本知识,本篇以一个小项目为例,详细说明django框架如何集成celery进行开发。本系列文章的开发环境:w
- 今天的这篇文章呢,小编来介绍一下如何通过Python来创建各种形式的文件,这里包括了文本文件CSV文件Excel文件压缩文件XML文件JSO
- 本节在这里主要说的是URLError还有HTTPError,以及对它们的一些处理。1.URLError首先解释下URLError可能产生的原
- 本文思路主要来源于实验楼的教程,但是一些具体的一些细节是我自己发现的,比如哪里获得站点对应的3位英文编号,怎么获得这个查询的url本文用到的
- 最近需要爬取某网站,无奈页面都是JS渲染后生成的,普通的爬虫框架搞不定,于是想到用Phantomjs搭一个代理。Python调用Phanto
- 入门scipy.optimize中,curve_fit函数可调用非线性最小二乘法进行函数拟合,例如,现在有一个高斯函数想要被拟合则调用方法如
- 这个问题用了我整整一晚上的时间才解决,希望有人遇到和我一样的时能少走些弯路。启动Django,服务器拒绝访问,可以尝试以下方法解决:1. 没