We help IT Professionals succeed at work.

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

533 Views
Last Modified: 2013-11-07
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

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Is "NewStructures" the right name? That is to say, it is not "NewStructure".

Author

Commented:
Yes it's the correct name...
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Can you open the file with it's default application--the file is not corrupt?

Author

Commented:
I can open it with Excel just fine...
CERTIFIED EXPERT
Author of the Year 2009

Commented:
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)  

Author

Commented:
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
CERTIFIED EXPERT
Author of the Year 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Holy cr@p...

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

Johnny
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.