begin transaction
declare @error int,@Task_Id int,@TEvents_Id int
set @error=0
insert into dbo.WeChat_Task (WFarm_Id)values ('0001')
--select @Task_Id=@@IDENTITY
set @Task_Id=@@IDENTITY
select @error=@error+@@ERROR
insert into dbo.WeChat_Task_Events(WFarm_Id,TEvents_Type,TEvents_Code,TEvents_Name,TargetId,StatusId,StatusText,PushId)values('0001','现场任务','xcrw','现场任务',@Task_Id,'1','待办','0')
select @TEvents_Id=@@IDENTITY
select @error=@error+@@ERROR
insert into dbo.WeChat_Task_EventsLog(TEvents_Id,TEvents_Code,TargetId,LogDescription,PushId)values(@TEvents_Id,'XCRW0001',@Task_Id,'生成一条现场任务','0')
select @error=@error+@@ERROR
select @TEvents_Id
if @error<>0
rollback tran
else
commit tran
//HTDbHelper.ExecuteNonQuery(sql);
//int Farm_Id = Convert.ToInt32(Repository.DataContext.ExecuteScalar(CommandType.Text, sql));
int task_id=Convert.ToInt32(HTDbHelper.ExecuteScalar(sql));
ExecuteScalar返回首行首列值
string Farm_Idsql = "SELECT Farm_ID FROM Base_Farm WHERE Farm_Name='" + farmname + "'";
int Farm_Id = Convert.ToInt32(Repository.DataContext.ExecuteScalar(CommandType.Text, Farm_Idsql));