111,128
社区成员
发帖
与我相关
我的任务
分享
foreach (DataRow dr in dt.Rows)
{
TransactionOptions option = new TransactionOptions();
//设置事务隔离级别
option.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, option))
{
try
{
UsersService.UpdateMember(u_guid, Promotion_lines, Promotion_lines2);
UsersService.InsertTiEHistory(u_guid, Promotion_lines, Promotion_lines2);
ts.Complete();
Logger.LOG_ERROR.Error("成功:" + u_phone);
SendMessage(u_phone);
}
catch (Exception ex)
{
Logger.LOG_ERROR.Error("失败:" + ex.Message);
}
finally
{
//释放资源
ts.Dispose();
}
}
}
insert语句
string sql = "INSERT INTO U_TiEHistory (u_guid,line1,line2,createdOn) VALUES (@u_guid,@line1,@line2,GETDATE())";
表结构
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[U_TiEHistory](
[id] [int] IDENTITY(1,1) NOT NULL,
[u_guid] [varchar](40) NULL,
[line1] [decimal](18, 2) NULL,
[line2] [decimal](18, 2) NULL,
[createdOn] [datetime] NULL,
CONSTRAINT [PK_TiEHistory] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO