hello,
i am uploading an excel file from my web application and is working fine from the local machine but gives an error "unspecified error" when i try to upload from another machine.
i have used oledb connection with Microsoft.Jet.OLEDB.4.0. i have kept 'impersonation = true' in my web.config file and all the rights are given to the user.
pls help me with this

Try this code :
My friend use this code to read excel file.

Protected Sub ActionUpload()
Dim MyConnection As OleDbConnection
Dim myPath As String = ""
Dim TableName As String = "TrxGCMSStatistic"
Dim CnSP As SqlClient.SqlConnection = Nothing

If FUAttach1.FileName <> "" Then
FUAttach1.SaveAs(Request.MapPath(Request.ApplicationPath) & "/Upload/GCMS/" & FUAttach1.FileName)
End If

myPath = Request.MapPath(Request.ApplicationPath) & "\Upload\GCMS\" & FUAttach1.FileName

Try
Dim objDS As DataSet = New DataSet
Dim objCmd As OleDbCommand
Dim objAdapter As OleDbDataAdapter = New OleDbDataAdapter

MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & myPath & ";Extended Properties=""Excel 8.0;IMEX=1;HDR=YES;""")
MyConnection.Open()

'Select the data from Sheet1 of the workbook.
objCmd = New OleDbCommand("select * from [Sheet1$]", MyConnection)

objAdapter.SelectCommand = objCmd
objAdapter.Fill(objDS, "XLData")

MyConnection.Close()

Catch ex As Exception
UserMsgBox(Me, ex.Message)
End Try
End Sub

This article has been dead for over six months. Start a new discussion instead.