Uploading Excel error

Discussion in 'ASP.NET / ASP.NET Core' started by avuman, Dec 1, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I'm having a problem when I upload an excel spreadsheet through the web server. It works fine when I run the command on the local machine, but once I run it using the website, it poops out. Here is the error I receive:


    "System.Data.Odbc.OdbcException: ERROR [HY000] [Microsoft][ODBC Excel Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x2500 Thread 0x9744 DBC 0x1635a24 Excel'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed ERROR [HY000] [Microsoft][ODBC Excel Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x2500 Thread 0x9744 DBC 0x1635a24 Excel'. ERROR [HY000] [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data. ERROR [HY000] [Microsoft][ODBC Excel Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x2500 Thread 0x9744 DBC 0x1635a24 Excel'. ERROR [HY000] [Microsoft][ODBC Excel Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x2500 Thread 0x9744 DBC 0x1635a24 Excel'. ERROR [HY000] [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data. at System.Data.Odbc.OdbcConnection.Open() at test1.clsSNSDB.UploadInventory(String path, String table) in C:\Inetpub\wwwroot\test1\clsSNSDB.vb:line 738"


    I've also tried running it using it the OLEDB driver, and a similar error comes up:


    "System.Data.OleDb.OleDbException: The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data. at System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) at System.Data.OleDb.OleDbConnection.InitializeProvider() at System.Data.OleDb.OleDbConnection.Open() at test1.clsSNSDB.UploadInventory(String path, String table) in C:\Inetpub\wwwroot\Test1\clsSNSDB.vb:line 742"


    I've already added the correct IUSR permissions, ODBC permissions, etc. And I've added permissions to the local TEMP directory. I'm all out of ideas, and any help would be greatly appreciated.





    Here is the code that I used for the class.


    Dim ConnectionString As String = "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;" & "Dbq=" & path


    Dim Con As New OdbcConnection(ConnectionString)


    Dim CmdSelect As New OdbcCommand("SELECT * FROM [Sheet1$]", Con)


    Dim Adapter As New OdbcDataAdapter(CmdSelect)


    Dim Ds As New DataSet


    Dim cmdProducts As New OdbcCommand


    Dim strSQL As String


    Dim strSQL2 As String


    Dim intCount As Integer = 0


    Dim dt As DataTable


    Try


    strSQL2 = "DELETE FROM " & table & ""


    '(ItemNumber, ProductDescription, SKU, ProductSize, LOC, Grade, Comments)


    cmdProducts.CommandText = strSQL2


    cmdProducts.Connection = Connection()


    cmdProducts.Connection.Open()


    cmdProducts.ExecuteNonQuery()


    cmdProducts.Connection.Close()


    Catch ex As Exception


    End Try


    Try


    Con.Open()


    Adapter.Fill(Ds, "Sheet1")


    dt = Ds.Tables("Sheet1")


    Do


    strSQL = "INSERT INTO " & table & " VALUES ('" & dt.Rows(intCount).Item(0) & "','" & dt.Rows(intCount).Item(1) & "', '" & dt.Rows(intCount).Item(2) & "', '" & dt.Rows(intCount).Item(3) & "','" & dt.Rows(intCount).Item(4) & "', '" & dt.Rows(intCount).Item(5) & "', '" & dt.Rows(intCount).Item(6) & "')"


    '(ItemNumber, ProductDescription, SKU, ProductSize, LOC, Grade, Comments)


    cmdProducts.CommandText = strSQL


    cmdProducts.Connection = Connection()


    cmdProducts.Connection.Open()


    cmdProducts.ExecuteNonQuery()


    cmdProducts.Connection.Close()


    intCount += 1


    Loop Until intCount = dt.Rows.Count


    Con.Close()


    Con.Dispose()


    Catch ex As Exception


    Return ex.ToString


    Finally


    Con.Close()


    End Try





    Again, any help would be greatly appreciated. Thanks.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    based on the error, you may have the wrong path to the excel file. Make sure you use the full path, ie. e:\web\[username]\htdocs\.....

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Sorry, I guess I forgot to mention that the path is supposed to be dynamic. The user is supposed to be able to browse to a file anywhere on their PC, and then upload it. Hence the path and not the full path.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page