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. Problem in Importing data from excel to database,please help me

Problem in Importing data from excel to database,please help me

Scheduled Pinned Locked Moved ASP.NET
helpdatabasecomdata-structures
1 Posts 1 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.
  • K Offline
    K Offline
    kishore19 hotmail com
    wrote on last edited by
    #1

    'Getting a file path If Not FILE1.PostedFile.FileName = "" Then FilePath = FILE1.PostedFile.FileName End If 'Excel Work Sheet Database Connection MyConnection = New System.Data.OleDb.OleDbConnection( _ "provider=Microsoft.Jet.OLEDB.4.0; " & _ "data source=" & FilePath & "; " & _ "Extended Properties=Excel 8.0;") 'Select the data from Sheet1 of the workbook. 'FilePath comes as c:\export\mydata.xls 'now i am going to retrive the "mydata" name only because of while iam storing the excel file,it is being stored as mydata.xls and at the same time sheet name also being changed as mydata whenever i am going to retrieve the data, i have to specify the sheet name for that i am doing the below code, but i am getting an error, it is alreday open by another user or some other error is displayed Dim f As Array f = Split(FilePath, "\") Dim k As Integer = f.Length Dim str As String = f(k - 1) Dim filename As String = str.Substring(0, str.LastIndexOf(".")) '' Select the data from Sheet1 of the workbook. MyCommand = New System.Data.OleDb.OleDbDataAdapter( _ "select * from [" & filename & "$]", MyConnection) DS = New System.Data.DataSet 'DataSet MyCommand.Fill(DS) 'Filling The dataset please help me, when iam going to export the data from database to excel, it is storing it as c1.xls(we give) and sheet1 name is also stored as c1.xls when i am going to retrieve the data from it, it is giving an error(as above said) please help me regards kishore go2kish@yahoo.com kishore

    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