2023年6月21日发(作者:)
C#实现SQL批量插⼊数据到表的⽅法本⽂实例讲述了C#实现SQL批量插⼊数据到表的⽅法。分享给⼤家供⼤家参考,具体如下:#region 帮助实例:SQL 批量插⼊数据 多种⽅法///
} } catch (Exception ex) { //throw ex; extLog("BulkToDB", e); } finally { (); if (bulkCopy != null) (); }}///
OPEN rs FETCH NEXT FROM rs INTO @tempStudentID WHILE @@FETCH_STATUS = 0 BEGIN Insert student (tempStudentID) values (@tempStudentID) FETCH NEXT FROM rs INTO @tempStudentID END CLOSE rs * *************************************************************** * create table Orders ( Orders_ID int identity(1,1) primary key, ItemCode nvarchar(50) not null, UM nvarchar(20) not null, Quantity decimal(18,6) not null, UnitPrice decimal(18,6) not null ) --创建⽤户⾃定义表类型,在可编程性->类型性->⽤户⾃定义表类型 create type OrdersTableType as table ( ItemCode nvarchar(50) not null, UM nvarchar(20) not null, Quantity decimal(18,6) not null, UnitPrice decimal(18,6) not null ) go create procedure Pro_Orders ( @OrdersCollection OrdersTableType readonly ) as insert into Orders([ItemCode],[UM],[Quantity],[UnitPrice]) SELECT oc.[ItemCode],oc.[UM],[Quantity],oc.[UnitPrice] FROM @OrdersCollection AS oc; go *
*/ SqlParameter[] parameters = {new SqlParameter("@OrdersCollection", ured)}; parameters[0].Value = sourceDataTable; new SQLHelper().ExecuteScalar("P_DataTable_ToHotelDB", parameters, true);}#endregion更多关于C#相关内容感兴趣的读者可查看本站专题:《》、《》、《》及《》希望本⽂所述对⼤家C#程序设计有所帮助。
2023年6月21日发(作者:)
C#实现SQL批量插⼊数据到表的⽅法本⽂实例讲述了C#实现SQL批量插⼊数据到表的⽅法。分享给⼤家供⼤家参考,具体如下:#region 帮助实例:SQL 批量插⼊数据 多种⽅法///
} } catch (Exception ex) { //throw ex; extLog("BulkToDB", e); } finally { (); if (bulkCopy != null) (); }}///
OPEN rs FETCH NEXT FROM rs INTO @tempStudentID WHILE @@FETCH_STATUS = 0 BEGIN Insert student (tempStudentID) values (@tempStudentID) FETCH NEXT FROM rs INTO @tempStudentID END CLOSE rs * *************************************************************** * create table Orders ( Orders_ID int identity(1,1) primary key, ItemCode nvarchar(50) not null, UM nvarchar(20) not null, Quantity decimal(18,6) not null, UnitPrice decimal(18,6) not null ) --创建⽤户⾃定义表类型,在可编程性->类型性->⽤户⾃定义表类型 create type OrdersTableType as table ( ItemCode nvarchar(50) not null, UM nvarchar(20) not null, Quantity decimal(18,6) not null, UnitPrice decimal(18,6) not null ) go create procedure Pro_Orders ( @OrdersCollection OrdersTableType readonly ) as insert into Orders([ItemCode],[UM],[Quantity],[UnitPrice]) SELECT oc.[ItemCode],oc.[UM],[Quantity],oc.[UnitPrice] FROM @OrdersCollection AS oc; go *
*/ SqlParameter[] parameters = {new SqlParameter("@OrdersCollection", ured)}; parameters[0].Value = sourceDataTable; new SQLHelper().ExecuteScalar("P_DataTable_ToHotelDB", parameters, true);}#endregion更多关于C#相关内容感兴趣的读者可查看本站专题:《》、《》、《》及《》希望本⽂所述对⼤家C#程序设计有所帮助。
发布评论