创建dBase数据库时如何指定数字宽度和精度?

发布于 2024-08-29 09:42:45 字数 510 浏览 4 评论 0原文

我们需要能够创建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮萍、无处依 2024-09-05 09:42:45

找不到解决方案,如果有人能想出一个解决方案,我将更改我接受的答案!

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

泼猴你往哪里跑 2024-09-05 09:42:45

您可以使用 Microsoft OLE DB Provider

使用以下连接:

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

并且您查询:

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

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) )"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文