Source: http://www.cnblogs.com/chenyuming507950417/p/3169267.html
Assume that the data in Excel is as follows:
The database creation table is as follows:
Here, Id is the auto-increment field:
Code:
Page_Load( FileSvr fileSvr = System.Data.DataTable dt = fileSvr.GetExcelDatatable(, System.Data.DataTable GetExcelDatatable( fileUrl, cmdText = System.Data.DataTable dt = OleDbConnection conn = OleDbConnection( (conn.State == ConnectionState.Broken || conn.State == System.Data.DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, sheetName = schemaTable.Rows[][ strSql = + sheetName + OleDbDataAdapter da = DataSet ds = dt = ds.Tables[ i = lng = lat = offsetLNG = offsetLAT = (DataRow dr lng = dr[ lat = dr[ offsetLNG = dr[ offsetLAT = dr[ strSql = .Format( strConnection = ConfigurationManager.ConnectionStrings[ SqlConnection sqlConnection = SqlCommand sqlCmd = sqlCmd.CommandText = sqlCmd.Connection = SqlDataReader sqlDataReader = i++ }
Running result: