writing excel file value into notepad using vb.net. in my code am using oledb provider for opening the excel file.but am getting error in openning the excel file. that file named as "phone data.xlsx" . stored in my system desktop.using file upload control to get that file.
my code
-------
Dim pathToCheck As String = filename
If System.IO.File.Exists(pathToCheck) = "True" Then
IO.File.Delete(filename)
End If
Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter("D:\modellog.txt", True, System.Text.Encoding.UTF8)
If FileUpload2.HasFile Then
TextBox1.Text = FileUpload2.FileName
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim Ds As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
Try
MyConnection = New System.Data.OleDb.OleDbConnection(("provider=Microsoft.ACE.OLEDB.12.0; " + ("data source=" _
+ (TextBox1.Text + ("; " + "Extended Properties=Excel 12.0;")))))
MyCommand = New System.Data.OleDb.OleDbDataAdapter _
("select * from [Sheet1$]", MyConnection)
Ds = New System.Data.DataSet
MyCommand.Fill(Ds)
error
-----
The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data.