connection string for dbf files

822
2
09-23-2022 07:19 AM
MarcHillman
New Contributor III

I am attempting to read the .dbf file associated with a .shp file to speed up the search for certain metadata, rather than querying the .shp file. I am having great difficulty formulating the correct connection string. I think that the .dbf files are in dBase III+ format, but I'm not sure. At run time I get an error when I open the .dbf file using the connection string below - "code -2147467259 - Unexpected error from external database driver (8961)". Any help in formulating the correct connection string would be much appreciated.

In an act of absolute desperation, I have reconstructed a .dbf file by querying the .shp file and producing a .dbf that is dBase IV using the connection string below, and it works, but I'd like to access the .dbf without having to reconstruct the .dbf file.

I am using an OleDbConnection connection.

 

Dim BaseConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Mode=Read;Extended Properties=dBase IV;"

 

Platform is Windows 10 64-bit

0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor

That's not an approach I've seen anyone take... we obviously recommend querying via the API (Method QueryFeaturesAsync (arcgis.com)).

That said, perhaps...

Check your connection string: From a quick search on StackOverflow it looks like the connecting string should include the directory name and you access each dbf file in that directory as a table of the database connection? e.g. c# - Read DBF file: System.Data.OleDb.OleDbException - Stack Overflow  

Take a look at the technical spec for Shapefile for dbf info: ESRI Shapefile Technical Description

 

0 Kudos
MarcHillman
New Contributor III

I do query by QueryFeaturesAsync (mostly) but in some performance related cases I use the .dbf file. The full connection string does include the directory name, but I only showed the bit that has the issue. When I use a dBase IV connection string, it works on the dBase IV .dbf that I created. I wish to use a connection string that works on the .dbf file that came with the .shp file.

0 Kudos