添加引用system.enterpriseservices.dll
using system.enterpriseservices;
随便建立一个按钮,在按钮中进行如下操作:
try
{
work1();
work2();
contextutil.setcomplete();
}
catch(system.exception except)
{
contextutil.setabort();
response.write(except.message);
}
然后在页面中添加2个操作,模拟一下在逻辑层调用不同类中的操作的情况
private void work1()
{
sqlconnection conn=new sqlconnection(system.configuration.configurationsettings.appsettings["conn"]);
sqlcommand cmd1=new sqlcommand("insert into trantest (id,test)values(1,test)",conn);
conn.open();
cmd1.executenonquery();
conn.close();
}
private void work2()
{
sqlconnection conn=new sqlconnection(system.configuration.configurationsettings.appsettings["conn"]);
sqlcommand cmd2=new sqlcommand("insert into trantest (id,test)values(2,test)",conn);
conn.open();
cmd2.executenonquery();
conn.close();
}