2023年7月14日发(作者:)
导⼊Excel数据⽂件实现页⾯选择查找⽂件,并导⼊以如下结构为模板的Excel数据⽂件
前台设计界⾯如下:在这⾥使⽤的FileUpload控件实现⽂件查找选择,前台代码如下:
AND [FirstPartStructure]=N'{3}' AND [SecondPartStructure]=N'{4}' ", strFactory, strWorkshop, strQualityDoor, strFirstPartStructure, strSecondPartStructure); ing_SQLExecuteScalar(strSqlDelete); string strSqlInsert = (@" INSERT INTO [Test].[dbo].[QMS_QualiryDoorAndParts] ([Factory] ,[Workshop] ,[QualityDoor] ,[FirstPartStructure] ,[SecondPartStructure]) VALUES (N'{0}' ,N'{1}' ,N'{2}' ,N'{3}' ,N'{4}') ",strFactory ,strWorkshop ,strQualityDoor,strFirstPartStructure, strSecondPartStructure); result = ing_SQLExecuteScalar(strSqlInsert).funInt_StringToInt(0); } } } if (result == 0 && i_count > 0) { erStartupScript(this, e(), "JsError", "alert('导⼊成功。');", true); } else if (i_count == 0) { erStartupScript(this, e(), "JsError", "alert('EXEC中的列名不符合规则。');", true); } } catch (Exception ex) { erStartupScript(this, e(), "JsError", "alert('Fail:" + e + "');", true); } } catch (Exception exp) { erStartupScript(this, e(), "JsError", "alert('Fail:" + e + "');", true); } }
后台完整实现代码如下:其中;是类似SQLHelper的⼀个引⽤using System;using c;using ;using ;using ;using trols;using ntrols;using ts;using ;using ;using uration;using ;namespace QualityDoorAndPartsCorrespondence{ public partial class QualityDoorAndPartsImport : { #页⾯属性... ///
ble schemaTable = DbSchemaTable(, null); OleDbDataAdapter sqlada = new OleDbDataAdapter(); foreach (DataRow dr in ) { try { string strSql = "Select * From [" + dr[2].ToString().Trim() + "]"; if (ns("$")) { OleDbCommand objCmd = new OleDbCommand(strSql, conn); Command = objCmd; (ds, dr[2].ToString().Trim()); } } catch { } } //关闭连接 (); } return ds; } catch (Exception ex) { erClientScriptBlock(, e(), "err", "alert('" + e + "');", false); return null; } } #⽅法... #事件... ///
AND [FirstPartStructure]=N'{3}' AND [SecondPartStructure]=N'{4}' ", strFactory, strWorkshop, strQualityDoor, strFirstPartStructure, strSecondPartStructure); ing_SQLExecuteScalar(strSqlDelete); string strSqlInsert = (@" INSERT INTO [Test].[dbo].[QMS_QualiryDoorAndParts] ([Factory] ,[Workshop] ,[QualityDoor] ,[FirstPartStructure] ,[SecondPartStructure]) VALUES (N'{0}' ,N'{1}' ,N'{2}' ,N'{3}' ,N'{4}') ",strFactory ,strWorkshop ,strQualityDoor,strFirstPartStructure, strSecondPartStructure); result = ing_SQLExecuteScalar(strSqlInsert).funInt_StringToInt(0); } } } if (result == 0 && i_count > 0) { erStartupScript(this, e(), "JsError", "alert('导⼊成功。');", true); } else if (i_count == 0) { erStartupScript(this, e(), "JsError", "alert('EXEC中的列名不符合规则。');", true); } } catch (Exception ex) { erStartupScript(this, e(), "JsError", "alert('Fail:" + e + "');", true); } } catch (Exception exp) { erStartupScript(this, e(), "JsError", "alert('Fail:" + e + "');", true); } } ///
发布者:admin,转转请注明出处:http://www.yc00.com/news/1689309609a228532.html
评论列表(0条)