How to specify numeric width and precision when creating a dBase database?
문제
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) )"
제휴하지 않습니다 StackOverflow