创建dBase数据库时如何指定数字宽度和精度?
我们需要能够创建一个 dBase 数据库(.dbf 文件),其中包含具有特定宽度和精度的数字列。我似乎可以设置精度但不能设置宽度。以下代码显示了我的连接字符串和命令文本。
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();
}
这在文件中提供了一个 Id,20,3
列。
一定有一种方法可以设置字段宽度,而无需手动编辑 .dbf 文件吗?在创建 shapefile 时没有其他人遇到过这个吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找不到解决方案,如果有人能想出一个解决方案,我将更改我接受的答案!
No solution could be found, if anyone can come up with one I will change my accepted answer!
您可以使用 Microsoft OLE DB Provider
使用以下连接:
并且您查询:
You can use Microsoft OLE DB Provider
Use the following conection:
and you query: