asp.net上传excel,怎么判断excel内容是否重复 各位大侠,请问asp.net上传excel,怎么判断excel内容是否重复, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 读取EXCEL判断DataTable里是否有重复 将excel中数据放到数据源中.然后对数据源进行判断! string excelConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\""; OleDbConnection clconnection = new OleDbConnection(excelConnectionStr); clconnection.Open(); DataTable dt = clconnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null); DropDownList2.DataSource = dt; DropDownList2.DataTextField = dt.Columns[2].ToString().Trim(); DropDownList2.DataBind(); clconnection.Close(); string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; string selecttext = "select * from [" + DropDownList2.SelectedItem.Text.ToString().Trim() + "]"; OleDbDataAdapter da = new OleDbDataAdapter(selecttext, excelConnectionString); DataSet ds = new DataSet(); da.Fill(ds); string excelConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; OleDbConnection olconnection = new OleDbConnection(excelConnectionStr); olconnection.Open(); OleDbCommand cmd = new OleDbCommand("select * from [" + DropDownList2.SelectedItem.Text.ToString().Trim() + "]", olconnection); OleDbDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { SqlConnection conn = BuildConnection.Buildsqlconnection(); SqlBulkCopy bulkcopy = new SqlBulkCopy(conn); for (int i = 0; i < CheckBoxList1.Items.Count; i++) { if (CheckBoxList1.Items[i].Selected == true) { bulkcopy.ColumnMappings.Add(CheckBoxList1.Items[i].Text.ToString().Trim(), CheckBoxList1.Items[i].Text.ToString().Trim()); choo = choo + CheckBoxList1.Items[i].Text.ToString().Trim() + ","; } } if (choo.Length > 0) { choo = choo.Substring(0, choo.Length - 1); } cmd.Connection.Close(); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); 刷新页面后ModalPopupExtender不隐藏了 treeview鼠标右键,高分! asp.net 2.0 在运行一个网站后,这个localhost:4039虾米意思? 求一条union的sql语句 求助,菜鸟问题. 求!!!!求1 求救: 网站慢问题 求加密方法,可以加可以解,谢 2005/8 举报.处理.建议专用贴(asp.net) window.open google maps api 问题 关于mvc中Controller疑问
判断DataTable里是否有重复
string excelConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\"";
OleDbConnection clconnection = new OleDbConnection(excelConnectionStr);
clconnection.Open();
DataTable dt = clconnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
DropDownList2.DataSource = dt;
DropDownList2.DataTextField = dt.Columns[2].ToString().Trim();
DropDownList2.DataBind();
clconnection.Close();
string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
string selecttext = "select * from [" + DropDownList2.SelectedItem.Text.ToString().Trim() + "]";
OleDbDataAdapter da = new OleDbDataAdapter(selecttext, excelConnectionString);
DataSet ds = new DataSet();
da.Fill(ds);
string excelConnectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
OleDbConnection olconnection = new OleDbConnection(excelConnectionStr);
olconnection.Open();
OleDbCommand cmd = new OleDbCommand("select * from [" + DropDownList2.SelectedItem.Text.ToString().Trim() + "]", olconnection);
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
SqlConnection conn = BuildConnection.Buildsqlconnection();
SqlBulkCopy bulkcopy = new SqlBulkCopy(conn);
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
bulkcopy.ColumnMappings.Add(CheckBoxList1.Items[i].Text.ToString().Trim(), CheckBoxList1.Items[i].Text.ToString().Trim());
choo = choo + CheckBoxList1.Items[i].Text.ToString().Trim() + ",";
}
}
if (choo.Length > 0)
{
choo = choo.Substring(0, choo.Length - 1);
}
cmd.Connection.Close();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);