熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#數據回滾實例

2013-11-13 10:32:21  來源: .NET編程 

  private void save_db(){

  SqlConnection conn = new SqlConnection(ConfigurationSettingsAppSettings[]ToString());

  SqlCommand comm = new SqlCommand();

  connOpen();

  SqlTransaction rollbk= connBeginTransaction();

  commConnection=conn;

  commTransaction=rollbk;

  try

  {

  for(i){

  commCommandText=insert into ;

  commExecuteNonQuery();

  }

  rollbkCommit();

  }

  catch(Exception exp)

  {

  rollbkRollback();

  ResponseWrite(save_fail);

  return;

  }

  finally

  {

  connClose();

  }

  ResponseWrite(save_ok);

  }


From:http://tw.wingwit.com/Article/program/net/201311/13944.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.