locked
OleDbException was caught: External table is not in the expected format. RRS feed

  • Question

  • User-2066177896 posted

    Hi,
    I am trying to read from a .dbf file in vb.net.This is my code.
    I am getting the following error.

    OleDbException was caught:
    External table is not in the expected format.

    Error in Detail:
    System.Data.OleDb.OleDbException: External table is not in the expected format.
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

    Can anyone tell me what is wrong here?

     

    Public Function getdatafromTripActivedbf() As DataTable
    
            Dim sFileFolder As String = Nothing
            sFileFolder = "C:\Users\me\Desktop\trip\" 
            Dim sConnectionStringOLEDB As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFileFolder & ";Extended Properties=dBASE IV;User ID=Admin;Password=;"
            Dim mycon As New OleDbConnection(sConnectionStringOLEDB)
            mycon.Open()
            Dim strquery As String = "Select * from TRIPACTV "
            Dim mycommand As New OleDbCommand(strquery, mycon)
            Try
                Dim myadapter As New OleDbDataAdapter(mycommand)
                myadapter.Fill(trpActvInfo)
                mycon.Close()
                Return trpActvInfo
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            Finally
                mycon.Close()
            End Try
            Return trpActvInfo
        End Function 
    


     

    Thursday, January 6, 2011 4:25 PM

All replies

  • User269602965 posted

    Since at first glance the code looks okay, then I think of operating system issues.

    The target folder:

    C:\Users\me\Desktop\trip\

    Check file permissions on this folder.

    Does your .NET (ASP.NET?) application user have permissions to tranverse the folder filenames and read file data? 

    Thursday, January 6, 2011 5:31 PM
  • User-2066177896 posted

    Hi Lannie,

    The user logged in has complete rights on the folder.

    How do i check if the application has the rights or not?

    (Forgot to mention that this is a winforms application. But does it matter? I posted here first by mistake and then in the winforms forum. No one reponded there yet)

     

    Thanks

     

     

    Thursday, January 6, 2011 6:01 PM