C#和sql结合,返回刚新增的ID主键的值
#region----新增一条预约活动表数据---- /// <summary> /// 新增一条预约活动表数据 /// </summary> /// <param name="appointmentEntity"></param> /// <returns></returns> public int InsertAppointment(Appointment appointmentEntity) { string sql = @" insert into Appointment ( BID,Title,PicUrl,ErpStoreID,Phone, AddressInfo,AddressMap,ApDesc,ApUseDesc,BeginDate, EndDate,Interval,AdvanceCycDay,LimiteBuy,LimiteBuy_Total, LimiteBuy_Day,LimiteBuy_Trade,IsNeedUserPhone,IsValPhone,CusInputeInfo, InterValType,InterValSize,Status,CreateDate,UpdateDate ) values ( @BID,@Title,@PicUrl,@ErpStoreID,@Phone, @AddressInfo,@AddressMap,@ApDesc,@ApUseDesc,@BeginDate, @EndDate,@Interval,@AdvanceCycDay,@LimiteBuy,@LimiteBuy_Total, @LimiteBuy_Day,@LimiteBuy_Trade,@IsNeedUserPhone,@IsValPhone,@CusInputeInfo, @InterValType,@InterValSize,@Status,@CreateDate,@UpdateDate ) SELECT @@IDENTITY as 'ApID' "; //ExecuteScalar,返回刚刚插入的ID的值 var insertResultId = _dbBase.ExecuteScalar(sql, appointmentEntity); int insertId = Convert.ToInt32(insertResultId); return insertId; } #endregion----新增一条预约活动表数据----
搜索
复制
标签:C#,新增,LimiteBuy,----,sql,主键,ID From: https://www.cnblogs.com/jankie1122/p/11109088.html