• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

    asp.net 使用事務(wù)

    來源:懂視網(wǎng) 責(zé)編:小采 時間:2020-11-27 22:43:25
    文檔

    asp.net 使用事務(wù)

    asp.net 使用事務(wù):ASP.NET操作事務(wù)非常的簡單,代碼如下: 代碼 代碼如下:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls
    推薦度:
    導(dǎo)讀asp.net 使用事務(wù):ASP.NET操作事務(wù)非常的簡單,代碼如下: 代碼 代碼如下:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls

    ASP.NET操作事務(wù)非常的簡單,代碼如下:
    代碼
    代碼如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
    using System.Transactions;
    public partial class swstudy : System.Web.UI.Page
    {
    private SqlConnection conn;
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    private SqlConnection GetConnection()
    {
    if (conn!=null&&conn.State == ConnectionState.Open)
    {
    return conn;
    }
    else
    {
    return conn= new SqlConnection("server=PC-200911131211;database=test;uid=sa;pwd=sa123456");
    }
    }
    //提交
    protected void Button1_Click(object sender, EventArgs e)
    {
    string str1 = this.TextBox1.Text;
    string str2 = this.TextBox2.Text;
    using (GetConnection())
    {
    conn.Open();
    //事務(wù)
    SqlTransaction tran;
    tran = conn.BeginTransaction();
    //提交一
    SqlCommand cmd1 = new SqlCommand("insert into m1(m1,m2)values('" + str1 + "','" + str2 + "')", conn);
    cmd1.Transaction = tran;
    //提交二
    SqlCommand cmd2 = new SqlCommand("insert into messages(msg)values('" + str1 + "')", conn);
    cmd2.Transaction = tran;
    try
    {
    cmd1.ExecuteNonQuery();
    cmd2.ExecuteNonQuery();
    tran.Commit();//提交事物
    Response.Write("<script>alert('全部提交OK')</script>");
    }
    catch
    {
    tran.Rollback();//回滾操作
    Response.Write("<script>alert('事務(wù)回滾')</script>");
    }
    finally
    {
    conn.Close();
    }
    }
    }
    }

    聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    asp.net 使用事務(wù)

    asp.net 使用事務(wù):ASP.NET操作事務(wù)非常的簡單,代碼如下: 代碼 代碼如下:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls
    推薦度:
    標(biāo)簽: 使用 事務(wù) ASP.NET
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 99热国内精品| 精品欧美激情在线看| 国产亚洲精品拍拍拍拍拍| 大桥未久在线精品视频在线| 无码日韩精品一区二区免费暖暖| 国产AⅤ精品一区二区三区久久| 精品国产VA久久久久久久冰| 日本熟妇亚洲欧美精品区| 国产精品日日摸夜夜添夜夜添1国产精品va欧美精 | 国内精品久久久人妻中文字幕| 四虎国产精品成人免费久久| 国产乱人伦精品一区二区在线观看| 精品久久一区二区| 动漫精品专区一区二区三区不卡| 久久久久无码精品国产| 亚洲精品国产精品乱码在线观看 | 综合久久精品色| 亚洲国产精品狼友中文久久久| 老司机精品影院91| 日韩福利视频精品专区| 欧美日韩国产精品系列| 青青热久久国产久精品| 亚洲欧美日韩久久精品| 亚洲欧美精品综合中文字幕| 中文字幕精品无码一区二区| 亚洲精品自产拍在线观看| 亚洲动漫精品无码av天堂 | 亚洲精品无码MV在线观看| 亚洲精品无码成人片久久| 亚洲精品二区国产综合野狼| 亚洲高清国产拍精品26U| 欧美精品中文字幕亚洲专区| 国内精品伊人久久久久AV影院| 国产成人精品日本亚洲网站| 99热这里只有精品在线| 久久亚洲国产精品一区二区| 国产精品 91 第一页| 久久精品国产亚洲Aⅴ香蕉| 香蕉99久久国产综合精品宅男自| 亚洲日韩国产精品乱| 久久精品麻豆日日躁夜夜躁|