문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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) )"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top