Link to home
Start Free TrialLog in
Avatar of NCSO
NCSO

asked on

Open dbf File gives error "Could not find object..."

Hi,

I am trying to open some dbf files and two of the three I am trying to open does so just fine, but the third one gives this error:

"The Microsoft jet database engine could not find the object 'NewStructures'.  Make sure the object exists and that you spell it's name and the path name correctly"

I know the file exist and this code works with two other dbf files placed in the same path.

Any ideas why it does not work?  

tnx
~j
Imports System.Data.OleDb
 
Public Class Form1
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ConnectionString As String
        Try
            ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\data\ncso\v2\GetAddresses\;Extended Properties=dBase IV"
            Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
            dBaseConnection.Open()
 
            Dim dBaseCommand As New System.Data.OleDb.OleDbCommand("SELECT * FROM NewStructures.dbf", dBaseConnection)
            Dim dBaseDataReader As System.Data.OleDb.OleDbDataReader = dBaseCommand.ExecuteReader(CommandBehavior.SequentialAccess)
 
            While dBaseDataReader.Read
                Console.WriteLine(dBaseDataReader("Column1").ToString)
                Console.WriteLine(dBaseDataReader("Column2").ToString)
                Console.WriteLine(dBaseDataReader("Column3").ToString)
            End While
 
            dBaseConnection.Close()
 
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class

Open in new window

Avatar of kaufmed
kaufmed
Flag of United States of America image

Is "NewStructures" the right name? That is to say, it is not "NewStructure".
Avatar of NCSO
NCSO

ASKER

Yes it's the correct name...
Can you open the file with it's default application--the file is not corrupt?
Avatar of NCSO

ASKER

I can open it with Excel just fine...
Do you have any other files in the directory that might confuse the issue, such as files with the same name but with a different file extension?
Also, show one of the SELECT commands that works.  Maybe I can see a difference.  Try it without .dbf and/or enclosed in brackets:
   ... .OleDbCommand("SELECT * FROM [NewStructures.dbf]", dBaseConnection)
   ... .OleDbCommand("SELECT * FROM [NewStructures]", dBaseConnection)  
Avatar of NCSO

ASKER

Hi,

I have tried with or without the .dbf, there are no other files with that name, and if I replace "newstructures" with "roads" (another database) the exact same code works perfectly.

Are there different versions of dbf files that might make the difference?

Thanks
~j
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NCSO

ASKER

Holy cr@p...

That was it...  I would never have thought of that... so thank you so much!

Johnny