ASP.NET中如何调用事务和触发器?

解决方案 »

  1.   

    事物:public   bool   SaveInforAssinRY(DataTable   Info)   
      {   
      bool   InsertFlag   =   true;   
      SqlConnection   sqlcon     =   new   SqlConnection(Configuration.ConnectionString);   
      sqlcon.Open();   
      int   mt   =   Info.Rows.Count;   
                              SqlTransaction   oSqlTran   =sqlcon.BeginTransaction();   
      try   
      {   
      for(int   i=0;i<Info.Rows.Count;i++)   
      {   
      //vCommandType,   string   vbsbh,string   vdxgcbh,string   vzymcid,string   vzymc,string   vzyryid,   
      //string   vzyrymc,string   vzgcbh,string   vRegeditMan   ,string   vRegeditDate   
      InsertEachAssinRY(sqlcon,oSqlTran,   
                                    Info.Rows[i]["CommandType"].ToString(),   
                                                                            Info.Rows[i]["bsbh"].ToString(),   
                                    Info.Rows[i]["dxgcbh"].ToString(),   
                                    Info.Rows[i]["zymcid"].ToString(),   
                                    Info.Rows[i]["zymc"].ToString(),   
                                    Info.Rows[i]["zyryid"].ToString(),   
                                            Info.Rows[i]["zyrymc"].ToString(),     
                                    Info.Rows[i]["zgcbh"].ToString(),     
                                    Info.Rows[i]["RegeditMan"].ToString(),     
                                    Info.Rows[i]["RegeditDate"].ToString(),   
                                                                                    Info.Rows[i]["ImprotanceLevel"].ToString()   
                                  );   
        
        
      }   
      oSqlTran.Commit();   
      }   
      catch(Exception   e)   
      {   
      oSqlTran.Rollback();   
      InsertFlag     =   false;   
      throw(e);   
      }   
      finally   
      {   
      sqlcon.Close();   
      sqlcon   =   null;   
      Info   =   null;   
        
      }   
                  return   InsertFlag;   
      }触发器,这个是数据库相关的,和ASP.NET没关系:
    http://blog.csdn.net/qixi0616/archive/2008/08/20/2800007.aspx