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();
}
 
相关文档:
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 ......
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.cs
using System;
using System.Text;
using System.Collections.Generic;
namespace Observer
{
public interface ISubject
{
void RegisterObserver(IOvserver o);
& ......
你首先要理解一下概念:
一 类型(Type) 对象是什么
比如 object x; x是对象,object就是它的类型,在程序中如何描述类型这个概念呢?
就是Type(System.Type)。要获取某个类的类型可以用typeof()操作符
object a;object b; DataTable t;
aType = typeof(object);Type bType = typeof(object);tType = typ ......