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

推荐订阅源

Y
Y Combinator Blog
B
Blog
S
SegmentFault 最新的问题
Vercel News
Vercel News
博客园 - 聂微东
宝玉的分享
宝玉的分享
C
Check Point Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
V
V2EX
爱范儿
爱范儿
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
博客园 - 司徒正美
博客园_首页
Last Week in AI
Last Week in AI
博客园 - 叶小钗
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
F
Fortinet All Blogs
腾讯CDC
J
Java Code Geeks

博客园 - 生活即技术

好久不更新了,忙的惭愧哦,思考一个应用 利用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)
  问题解决。