OleDbDataReader not reading only???
Hello all
Can someone please help :)
I am building an app to read a customers .xls file in to a array list
the array is the being reordered and im writing a file out the back end.
its doing several lookups in the .xls file to see if relivant data is there and it writes a different file (9 different specs) depending what is in each line/column.
Sound simple and I have the app working great however when I use a customers live data I get an ex.message = "Could not decrypt file"
the file opens in excel witthout any password prompts however it does look like the sheet is write protected but all im doing in my app is reading the data.
Any ideas?
Code:
Using fileConn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & OpenFileDialog1.FileName & "; Extended Properties='Excel 12.0 Xml; HDR=yes; IMEX=1'")
fileConn.Open()
''read the tables as specified
MyTableName = fileConn.GetSchema("Tables").Rows(0)("TABLE_Name") '1 is the sheet to be read
Dim OLEDBSearch As OleDbCommand = fileConn.CreateCommand
OLEDBSearch.CommandText = "SELECT * FROM [" & MyTableName & "];"
'OLEDBSearch.ExecuteNonQuery()
Dim OleDBDR As OleDbDataReader = OLEDBSearch.ExecuteReader
Dim Counter As Integer = 0
Dim isfirst As Boolean = True
'' Use the OleDB datareader to read each line
While OleDBDR.Read
'Counter += 1
If OleDBDR.Item(0).ToString.Trim <> "" Then
'' Selecting the Currency and Booktype Datareader Items
Dim Currency As String = OleDBDR.Item(4).ToString
Dim BookType As String = OleDBDR.Item(16).ToString
If isfirst Then
For intCount As Integer = 0 To OleDBDR.FieldCount - 1
Next
isfirst = False
End If
Dim TheLine As String = ""
Dim tempstring As String = ""
For intCount As Integer = 0 To OleDBDR.FieldCount - 1
tempstring &= (OleDBDR.Item(intCount).ToString) & "|"
Next
Re: OleDbDataReader not reading only???
OK well it seems that it has nothing to do with protected sheet.... any ideas please??:wave: