using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text;
public partial class 多数据插入临时表 : System.Web.UI.Page
{
SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.MakeDataTable();
this.GridView1.DataSource = this.InsertTable;
this.GridView1.DataBind();
}
}
protected void MakeDataTable()
{
this.InsertTable = new DataTable();
DataColumn nameCol = new DataColumn("EmpName", typeof(string));
DataColumn describeCol = new DataColumn("EmpDescribe", typeof(string));
DataColumn usageCol=new DataColumn("EmpUsage",type
多行数据插入,使用临时表
最新推荐文章于 2021-09-01 14:02:31 发布
这篇博客介绍了如何在ASP.NET中利用SqlTransaction对象进行事务处理,防止数据脏写。通过SqlConnection的BeginTransaction()方法创建事务,确保数据完整性。同时,文章提到了将数据先存入临时表,再批量插入数据库,但未提及如何处理唯一性验证,可能导致重复插入的问题。
摘要由CSDN通过智能技术生成