Results 1 to 2 of 2

Thread: OleDbDataReader not reading only???

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2009
    Posts
    31

    Angry 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

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2009
    Posts
    31

    Re: OleDbDataReader not reading only???

    OK well it seems that it has nothing to do with protected sheet.... any ideas please??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width