using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Common;

public partial class TransactionSqlDatasource : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
s2.UpdateParameters["test_time"].DefaultValue = DateTime.Now.ToShortDateString();
s2.UpdateParameters["class"].DefaultValue = "政治";
s2.UpdateParameters["title"].DefaultValue = "柯文哲:法務部勿把阿扁賴給醫療";
s2.UpdateParameters["summary"].DefaultValue = "羅瑩雪昨日下午召開記者會說,依台中監獄日常生活觀察紀錄,陳前總統作息規律,飲食正常,親友接見頻繁,似不符保外醫治之規定。";
s2.UpdateParameters["article"].DefaultValue = "但記者會上,羅瑩雪也指出,陳前總統病情若有變化,將考慮擴大鑑定小組,共同評估。對此,台北市長當選人柯文哲強調,「醫療上若10個專家都這樣說,加入第11個會不同?坦白說,不用了,不要在把問題賴在醫療上,政治問題政治解決,請馬總統要發揮政治智慧,朝讓台灣社會造成最小傷害的邏輯思考」。";
s2.UpdateParameters["author"].DefaultValue = "510";
s2.UpdateParameters["id"].DefaultValue = "72";
s2.Update();

 

}
protected void s2_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
DbCommand cmd = e.Command;
DbConnection conn = cmd.Connection;
conn.Open();
DbTransaction tran = conn.BeginTransaction();
cmd.Transaction = tran;
}
protected void s2_Updated(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.Exception == null)
{
e.Command.Transaction.Commit();
Response.Write("Transaction Success");

}
else
{
e.Command.Transaction.Rollback();
Response.Write("Transaction failure"+e.Exception.ToString());
}
GridView1.DataBind();
}
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 ylw1125 的頭像
    ylw1125

    程式搜集分享精靈

    ylw1125 發表在 痞客邦 留言(0) 人氣()