This may be simple but it eascapes me...
What i'm doing is reading data from Excel to a datareader. I don't have a problem with doing that. My problem is trying to point to the Excel file on a user local machine. If i hard code the path i'm fine. I was playing around with the fileupload control but every time i try to read the path it points to the wrong path. My research found that it is a security issue. Is it possible to point to a file on a users pc and read from it?
What i'm doing is reading data from Excel to a datareader. I don't have a problem with doing that. My problem is trying to point to the Excel file on a user local machine. If i hard code the path i'm fine. I was playing around with the fileupload control but every time i try to read the path it points to the wrong path. My research found that it is a security issue. Is it possible to point to a file on a users pc and read from it?
Code:
Dim strName As String
strName = Path.GetFileName(txtExcelFile.PostedFile.FileName)
Me.Label1.Text = Path.GetFullPath(strName).ToString
Dim DBConnection = New Data.OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:/Test/" & strName & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes""")
DBConnection.Open()
Dim SQLString As String = "SELECT * FROM [elecInfo$]"
Dim DBCommand = New Data.OleDb.OleDbCommand(SQLString, DBConnection)
Dim DBReader As Data.IDataReader = DBCommand.ExecuteReader()
gv.DataSource = DBReader
gv.DataBind()
DBReader.Close()
DBConnection.Close()