惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
量子位
博客园 - 司徒正美
V
V2EX
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
N
Netflix TechBlog - Medium
L
LangChain Blog
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 生活即技术

好久不更新了,忙的惭愧哦,思考一个应用 利用dataTable 排序的解决方法 项目中遇到的一些小问题及解决方法 常用代码 一个com+消息队列的例子 部署Com+ 2004我的爱,2005我的期待 加密解密相关 生成略缩图 论坛在线人数统计代码 正则表达式(1) 又一新的分页方法(转帖) 用户控件的使用(二) 用户控件的使用(一) DataList的使用(二)自定义分页的实现 DataList的使用(1) DataGrid的使用(2)自定义分页 DataGrid的使用(1)
上礼拜六犯的愚蠢错误
生活即技术 · 2004-11-29 · via 博客园 - 生活即技术

 上礼拜六 写了这样一段事务处理的代码。           
            on error resume next 
               Dim Myconn As New SqlClient.SqlConnection
                Dim Mycmd As New SqlClient.SqlCommand
                Dim str As String = System.Configuration.ConfigurationSettings.AppSettings("Connstr")
                Myconn.ConnectionString = str
                Myconn.Open()
                Dim trans As SqlClient.SqlTransaction = Myconn.BeginTransaction         
               Mycmd.Connection = Myconn
                Mycmd.Transaction = trans
    执行内容略 
                Mycmd.ExecuteNonQuery()
                if err.number<>0 then                         ' 检测是否有错误
                   trans.commit()
                   myconn.close
                  else 
                    trans.rollback()
                     myconn.close
                     response.write(err.description)
                  end if
   结果出现了错误。 
   错误描述是:事务对象未初始化等等
   是什么原因呢?事务对象未初始化。考虑的方向应该是定义事务对象这方面。可惜当天没有解决。回家后也是在想这个问题。
   到了今天在明白。
   Dim trans As SqlClient.SqlTransaction = Myconn.BeginTransaction         
   Myconn.Beging.Transaction 应该有参数,真是苯呀。
   最后根据自己的需要用了 
  Dim trans As SqlClient.SqlTransaction = Myconn.BeginTransaction(IsolationLevel.RepeatableRead)
  问题解决。