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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Import data from Excel sheet to sql Database-asp.net 2.0

Import data from Excel sheet to sql Database-asp.net 2.0

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-nethelp
3 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.
  • M Offline
    M Offline
    Member 4659001
    wrote on last edited by
    #1

    Currently I need to write a code To Import data from Excel sheet to sql Database-asp.net 2.0 I Have Written A function For It Function Is Given Below ; But as i execute it it gives Error Meaasge "The Microsoft Jet database engine cannot open the file 'D:\'. It is already opened exclusively by another user, or you need permission to view its data." I Have Order.xls File In D Drive protected void btnUpload_Click1(object sender, EventArgs e) { string PathtoTextFile = ("D:\\"); Response.Write(PathtoTextFile); System.Data.OleDb.OleDbConnection oCon = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\;Extended Properties= \"Excel 8.0;HDR=no;IMEX=1 \""); System.Data.OleDb.OleDbDataAdapter oCmd = new System.Data.OleDb.OleDbDataAdapter("select * from Order.xls", oCon); DataSet myDS = new DataSet(); oCmd.Fill(myDS); oCon.Close(); }

    Raghvendra

    G 1 Reply Last reply
    0
    • M Member 4659001

      Currently I need to write a code To Import data from Excel sheet to sql Database-asp.net 2.0 I Have Written A function For It Function Is Given Below ; But as i execute it it gives Error Meaasge "The Microsoft Jet database engine cannot open the file 'D:\'. It is already opened exclusively by another user, or you need permission to view its data." I Have Order.xls File In D Drive protected void btnUpload_Click1(object sender, EventArgs e) { string PathtoTextFile = ("D:\\"); Response.Write(PathtoTextFile); System.Data.OleDb.OleDbConnection oCon = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\;Extended Properties= \"Excel 8.0;HDR=no;IMEX=1 \""); System.Data.OleDb.OleDbDataAdapter oCmd = new System.Data.OleDb.OleDbDataAdapter("select * from Order.xls", oCon); DataSet myDS = new DataSet(); oCmd.Fill(myDS); oCon.Close(); }

      Raghvendra

      G Offline
      G Offline
      Greg Chelstowski
      wrote on last edited by
      #2

      You need to pass the filename in the data source, in the connection string, dude. You're on the right path, though. And then, the sql you wrote ("select * from Order.xls") should really be ("select * from Sheet1"), or whatever your Sheet is called in that excel spreadsheet. The rest seems fine... Except I would use a DataTable, and not a DataSet. Easier that way ;)

      var question = (_2b || !(_2b));

      M 1 Reply Last reply
      0
      • G Greg Chelstowski

        You need to pass the filename in the data source, in the connection string, dude. You're on the right path, though. And then, the sql you wrote ("select * from Order.xls") should really be ("select * from Sheet1"), or whatever your Sheet is called in that excel spreadsheet. The rest seems fine... Except I would use a DataTable, and not a DataSet. Easier that way ;)

        var question = (_2b || !(_2b));

        M Offline
        M Offline
        Member 4659001
        wrote on last edited by
        #3

        Thanks For Reply, I did the same as u instructed , But Still Having Same Error

        Raghvendra

        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