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

C#數據回滾實例

2022-06-13   來源: .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-2022 電腦知識網 Computer Knowledge   All rights reserved.