获取错误"无法执行本机批量操作查询"在C#

时间:2015-05-13 09:07:44

标签: c# sql-server-2012

private static void ExecuteSampleDDLCommands(ISession session)
{
    // Write the sql
    string ddlCommands=" begin 
            if exists(select * from dbo.sysobjects where id = object_id(N'test_bus_bkp') and OBJECTPROPERTY(id, N'IsUserTable') = 1) 
            begin 
              insert into test_bus_bkp (c_Bus_Id, c_UID, c_BusName, c_BusLocation) 
                  select c_Bus_Id, c_UID, c_BusName, c_BusLocation from test_bus
              Delete from test_bus
              insert into test_bus (c_Bus_Id,c_UID, c_BusName, c_BusLocation) 
              select c_Bus_Id,c_UID, c_BusName, c_BusLocation from test_bus_bkp
            end; 
            else 
            begin 
             select * into test_bus_bkp from test_bus
             Delete from test_bus
             insert into test_bus (c_Bus_Id, c_UID, c_BusName, c_BusLocation) 
             select c_Bus_Id, c_UID, c_BusName, c_BusLocation from t_bus_bkp
             end; 
          end;";

    IQuery query = session.CreateSQLQuery(ddlCommands);
    query.ExecuteUpdate();

}

我正在尝试在if exists,insert,delete中实施NHibernate数据访问方法。我的数据库是Microsoft SQL Server 2012。

尝试通过C#运行此代码时出现错误:

  

无法执行本机批量操作查询

为什么我收到此错误?

0 个答案:

没有答案