Reading a shapefile (DBF), name too long. RRS feed

  • Question

  • I am connecting to a GIS shapefile DBF directly with ADO.NET using the following connection string, "Driver={Microsoft dBASE Driver (*.dbf)};driverid=277;dbq=M:\GISdata"  I can create a dataset from a dbase datatable without problem as long is the shapefile name is shorter than 13 characters in length.  Otherwise, when I attempt to open a database named (for example) filenametoolong.shp (basename is 15 characters in length), I receive the following error message "You might not have permission to perform this operation, or the object filenametoolong might no longer exist in the database."  If I have created a dataset from the the filenametoolong.dbf, I cannot use that dataset for the creation of datagrids, etc.  If I shorten the name to (for example) filenametoo.shp (base name is 11 characters in length) the file opens just file and I can see all the data.  Is there a workaround other than shortening the names of all of our many, many shapefiles? 


    Salt Lake
    Thursday, November 19, 2009 8:43 PM


All replies

  • you can temporarily rename process by creating a temporary copy or you can look at (short-named) or you can try Visual Fox Pro.
    Friday, November 20, 2009 7:51 AM
  • Hi Craig,

    Could you make sure that you have the permission to access this file?
    And you can also try other provider for connection,

    Best Regards
    Yichun Feng

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 23, 2009 7:54 AM
  • I have full rights in this directory.  The only difference between being able to open the file with .NET and not appears to be the file name length.  My next step is to use short file names to access the files.  As there are many shapefiles with similar names, this will not prove to be a simple solution.  I have likewise tried a number of different forms for the connection string with no better results.
    Salt Lake
    Monday, November 23, 2009 12:18 PM
  • Yes, unfortunately dBase, Paradox, etc. file names are limited by the 8.3 standard when using either the ODBC or Jet OLEDB/ISAM drivers. You will need to rename the files to satisfy this spec before attempting to open them.
    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by CraigWMiller Tuesday, November 24, 2009 2:19 PM
    • Unmarked as answer by CraigWMiller Tuesday, November 24, 2009 4:57 PM
    Tuesday, November 24, 2009 2:07 PM
  • OK, I think I may have a workaround. Try using the Visual FoxPro OLEDB Provider. If it's not installed you can download it:

    The following worked for me:

    Connection string example -

    "Provider=VFPOLEDB;Data Source=C:\Documents and Settings\...\My Documents\My Database\dbase;Exclusive=Yes;Collating Sequence=machine"

    SQL statement -

    "SELECT * FROM dBaseTesting123.DBF"

    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by CraigWMiller Tuesday, November 24, 2009 4:57 PM
    Tuesday, November 24, 2009 2:29 PM
  • Thanks!  However, in the server explorer for Visual Studio 2005, it complains that there is not a DSN for Foxpro on my machine (although I do have Foxpro loaded).  I am guessing that I need to add a DSN in the Data Sources (ODBC) manager for Computer Administration.  I am not certain exactly how that is to be accomplished, but I'll give it a try.  I believe this is the likely solution.

    Thanks for your time and knowledge.
    Salt Lake
    Tuesday, November 24, 2009 5:02 PM
  • I was wrong.  It was one of the databases I could have used.  I just didn't consider the difference between Foxpro and a dBase file.  I'm a little more educated now.


    Salt Lake
    Tuesday, November 24, 2009 5:10 PM
  • Just an FYI, the OLEDB provider doesn't use a DSN. Only the ODBC drivers use this technology.

    Paul ~~~~ Microsoft MVP (Visual Basic)
    Tuesday, November 24, 2009 6:36 PM