修复 Float 和 Numeric 字段类型之间的差异

发布于 2024-12-23 01:23:22 字数 987 浏览 2 评论 0原文

我有两个 dbf 表,必须按列(字段)类型对它们进行比较。例如:

表 1:Id(数字)|姓名(角色)|薪资(数字)
表 2:Id(数字)|姓名(角色)| Salary (Float)

对于这两个表,程序应该显示类似的消息(字段 SALARY [F <> N] 中的类型不匹配),其中 F 是浮点型,N 是数字型。

所以我找不到这个字段之间的区别,因为对于这两个表,

    Using cmd2 As New OleDb.OleDbCommand("select * from Table1", connection)
                    Dim reader As OleDb.OleDbDataReader
                    reader = cmd2.ExecuteReader()

    reader.GetDataTypeName(2) 'returns DBTYPE_NUMERIC
    reader.GetFieldType(2) 'returns System.Decimal
End Using

    Using cmd3 As New OleDb.OleDbCommand("select * from Table2", connection)
                    Dim reader2 As OleDb.OleDbDataReader
                    reader2 = cmd3.ExecuteReader()

    reader2.GetDataTypeName(2) 'returns DBTYPE_NUMERIC
    reader2.GetFieldType(2) 'returns System.Decimal
End Using

我可以通过在记事本中打开 dbf 文件来查看 dbf 标头中的“F”和“N”字符,但无法将其读取到 VB,我认为这不是也是个好主意。

遇到这个问题我该怎么办?

I have two dbf tables and must compare them by column (field) types. For example:

Table1: Id (Numeric) | Name (Character) | Salary (Numeric)
Table2: Id (Numeric) | Name (Character) | Salary (Float)

With these two tables program should display message like (types do not match in field SALARY [F <> N]) where F is float and N is numeric.

So I can't find the difference between this fields because for both tables

    Using cmd2 As New OleDb.OleDbCommand("select * from Table1", connection)
                    Dim reader As OleDb.OleDbDataReader
                    reader = cmd2.ExecuteReader()

    reader.GetDataTypeName(2) 'returns DBTYPE_NUMERIC
    reader.GetFieldType(2) 'returns System.Decimal
End Using

    Using cmd3 As New OleDb.OleDbCommand("select * from Table2", connection)
                    Dim reader2 As OleDb.OleDbDataReader
                    reader2 = cmd3.ExecuteReader()

    reader2.GetDataTypeName(2) 'returns DBTYPE_NUMERIC
    reader2.GetFieldType(2) 'returns System.Decimal
End Using

I can view 'F' and 'N' characters in dbf header by opening dbf file in Notepad but can't read it to VB and I don't think it's good idea too.

What can I do with this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

〗斷ホ乔殘χμё〖 2024-12-30 01:23:22

FN 类型完全相同,它们之间没有区别。

更有用的区别是它们的设置,因为您可以指定字段中存储多少位数字和多少位小数。

不幸的是,我不知道如何在 VB.Net 中检查这一点。

The F and N types are exactly the same, there is no difference between them.

A more useful distinction would be their setup, as you can specify how many digits and how many decimal places are stored in the field.

Unfortunately, I do not know how to check for that in VB.Net.

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