How to specify numeric width and precision when creating a dBase database?
Posted
by Stevo3000
on Stack Overflow
See other posts from Stack Overflow
or by Stevo3000
Published on 2010-04-13T15:07:45Z
Indexed on
2010/04/15
7:43 UTC
Read the original article
Hit count: 361
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?
© Stack Overflow or respective owner