1
votes

We need to be able to create a dBase database (.dbf file) containing numeric columns with specific width and precision. I seem to be able to set the precision but not the width. The following code shows my connection string and my command text.

using (OleDbConnection oConnection = new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = {0};Extended Properties=dBase 5.0", msPath)))
{

  ....

  oCommand.CommandText = "CREATE TABLE [Field] ([Id] Numeric (15, 3))";
  oCommand.ExecuteNonQuery();
}

This gives me a column Id,20,3 in the file.

There must be a way to set the field width without resorting to editing the .dbf file manually? Has nobody else come across this before when creating shapefiles?

2
@Andrew Kalashnikov - No, we never resolved this issue. The consumer of our shape files loosened their requirements.stevehipwell

2 Answers

0
votes

No solution could be found, if anyone can come up with one I will change my accepted answer!

0
votes

You can use Microsoft OLE DB Provider

Use the following conection:

connectionString = @"Provider=vfpoledb.1;Data Source=" + path + ";Collating Sequence=machine;";

and you query:

comm.CommandText = "Create table Test (FirstName Numeric(4,0),LastName Char(50) )"