Excel to MySQL
-
Hi, I am working in ASP.Net and I want to export data from an Excel file to the MySQL. In SQL SERVER 2005, I use SQLBULKCOPY for doing the same. Is there any alternative of doing the same for mySQL also. Thanks is Advance,
-
Hi, I am working in ASP.Net and I want to export data from an Excel file to the MySQL. In SQL SERVER 2005, I use SQLBULKCOPY for doing the same. Is there any alternative of doing the same for mySQL also. Thanks is Advance,
Read Records one by one from the sheet and insert it into the desired table. the below function will help you in returning table from the Excel Sheet but the sheet name should be Sheet1. if change ..then change the code i have highlighted with underline(bold) public DataTable getDataFromXLS(string strFilePath) { try { string strConnectionString = string.Empty; strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strFilePath + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection cnCSV = new OleDbConnection(strConnectionString); cnCSV.Open(); OleDbCommand cmdSelect = new OleDbCommand(@"SELECT * FROM [Sheet1$]", cnCSV); OleDbDataAdapter daCSV = new OleDbDataAdapter(); daCSV.SelectCommand = cmdSelect; DataTable dtCSV = new DataTable(); daCSV.Fill(dtCSV); cnCSV.Close(); daCSV = null; return dtCSV; } catch (Exception ex) { return null; } finally { } }