Import mobile phone numbers to the database in batches. Idea: First upload the file to be imported to the project, then read each row of data in the file and insert it into the database. After the operation, delete the uploaded file. Example: Excel: notepad: front-end code:
<Div = id = runat = visible => <fieldset> <p> <label> </label> <asp: fileUpload ID = runat =/> <= runat = ErrorMessage = ControlToValidate => </asp: requiredFieldValidator> </p> <label> file example </label> </p> </fieldset> <div => </div> <div => </div> <div style => <asp: button ID = runat = Text = CssClass ==/> & nbsp; & <input = type = value = onclick =/> </div> <div = id = runat = visible => <fieldset> <p> <label> </label> <asp: fileUpload ID = runat =/> <= runat = ErrorMessage => </asp: requiredFieldValidator> </p> <label> file example </label> </p> </fieldset> <div => </div> <div => </div> <div style => <asp: button ID = runat = Text = CssClass ==/> & nbsp; & <input = type = value = onclick =/> </div>
Background code
btnExcel_Click( backStr= UploadFile(FileUpload1, , (backStr == Js.ShowSureMsgBox(.Page, (backStr == .Page, url = backStr; DataTable dt = (dt.Rows.Count > ( i = ; i < dt.Rows.Count; i++ {
phoneNum= dt.Rows[i][].ToString(); } .Page, btnNotepad_Click( backStr = UploadFile(FileUpload2, , (backStr == .Page, (backStr == .Page, url = backStr; DataTable dt = (dt.Rows.Count > ( i = ; i < dt.Rows.Count; i++
phoneNum= dt.Rows[i][].ToString(); }
} .Page, UploadFile(FileUpload FileUploadName, varfilename, (FileUploadName.HasFile) fileExtension = System.IO.Path.GetExtension(FileUploadName.FileName).ToLower(); (type == (fileExtension != && fileExtension != (type == (fileExtension != fpath = System.Web.HttpContext.Current.Server.MapPath( + varfilename + ); (!Directory.Exists(fpath)) time = DateTime.Now.ToString(); picturename = time + newFilePath = fpath + picturename; newFilePath; ; DataTable ExcelToDataSet( strCon = + filename + = = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, [] { , , , [] strTableNames = ( k = ; k < dtSheetName.Rows.Count; k++= dtSheetName.Rows[k][= = strExcel = + strTableNames[] + = DataTable ReadTXT(= = , System.Type.GetType( sLine = (sLine != = (sLine != && !sLine.Equals(=] =