易截截图软件、单文件、免安装、纯绿色、仅160KB

c#事务回滚

c#事务回滚(转)
作者:xue5ya  来源:博客园  发布时间:2009-03-20 16:08  阅读:263 次  原文链接   [收藏]  
Code
public void UpdateContactTableByDataSet(DataSet ds,string strTblName) 

    try 
    { 
        string strConnection ="server = ;database = ;uid = ;pwd = ;Connec Timeout = 60 ";
        SqlDataAdapter myAdapter = new SqlDataAdapter(); 
        SqlConnection  conn = new SqlConnection(strConnection); 
        SqlCommand myCommand = new SqlCommand("select * from strTblName",conn); 
        myAdapter.SelectCommand = myCommand; 
        SqlCommandBuilder myCommandBuilder = new SqlCommandBuilder(myAdapter);
        
        conn.Open(); 
        SqlTransaction myTrans = conn.BeginTransaction(); 
        myCommand.Transaction = myTrans;
    
        try 
        { 
            myAdapter.Update(ds,strTblName); 
            myTrans.Commit(); 
        } 
        


相关文档:

C#查询数据库把结果输出到XML的例子

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
//sqlserver身份验证
//s ......

C#创建XML

1 using System;
 2 using System.Collections;
 3 using System.Configuration;
 4 using System.Data;
 5 using System.Linq;
 6 using System.Web;
 7 using System.Web.Security;
 8 using&nbs ......

Observer 观察者模式 (HeadFirst设计模式 c#)

Observer.cs
using System;
using System.Text;
using System.Collections.Generic;
namespace Observer
{
   
    public interface ISubject
    {
        void RegisterObserver(IOvserver o);
    & ......

C#中如何理解【反射】技术

你首先要理解一下概念:
 一 类型(Type) 对象是什么
比如 object x; x是对象,object就是它的类型,在程序中如何描述类型这个概念呢?
就是Type(System.Type)。要获取某个类的类型可以用typeof()操作符
 object a;object b; DataTable t;
aType = typeof(object);Type bType = typeof(object);tType = typ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号