Help with importing excel files

Discussion in '.NET' started by pmb88, Feb 26, 2012.

  1. pmb88

    pmb88

    Joined:
    Jan 25, 2011
    Messages:
    3
    I am creating a web application that imports excel files into a database. What occurs is that i have several excel files that I need to import from excel into a database. These files could be excel 97-2003 or excel 2007/2010. I have it determine which filetype it is and use the particular connection. This is how my code looks.
    Code:
    Dim strconn As String
           If fileextesnison = ".xlsx" Then
                strconn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filepath + 
      ";Extended Properties=""Excel 12.0 Xml;"";"
          ELSE
                strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath+ 
    ";Extended Properties=""Excel 8.0;"";"
          End if
    Dim strSQL as string = "SELECT * FROM RangeName"
    Dim olConn As New OleDbConnection(strconn)
    Dim oadapter As OleDbDataAdapter
        olConn.Open()
    Dim od As New OleDbCommand(strSQL, olConn)
        oadapter.selectcommand = od
    Dim oData as dataset 
           oadapter.fill(odata, "Data")
           olConn.Close()
    
    Before the above process happens I am using softartisan excel writer to add a range name cause I am using the range name to select the data and adding [ and ] in the column names in case the column names are not valid database column name format. The issue is that when I try to import the file that is excel 97-2003 it gives me the microsoft jet database engine could not find 'RangeName' and please make sure that the path and filename is correct. When I try this with excel 2007/2010 it imports the file and have no issues. I have checked the filepath and it is directing to the proper file. What could be the issue that is occurring here?
     
    Last edited: Feb 26, 2012
    pmb88, Feb 26, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ed Bangle
    Replies:
    0
    Views:
    330
    Ed Bangle
    Nov 23, 2003
  2. plb
    Replies:
    2
    Views:
    354
  3. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,525
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  4. Mircescu Andrei
    Replies:
    3
    Views:
    92
    Mircescu Andrei
    Feb 20, 2014
Loading...

Share This Page