Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Excel to MySQL

Excel to MySQL

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasemysqlsql-server
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    astrovirgin
    wrote on last edited by
    #1

    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,

    Z 1 Reply Last reply
    0
    • A astrovirgin

      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,

      Z Offline
      Z Offline
      Zafar A khan
      wrote on last edited by
      #2

      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 { } }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups