修复 Float 和 Numeric 字段类型之间的差异
我有两个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
F
和N
类型完全相同,它们之间没有区别。更有用的区别是它们的设置,因为您可以指定字段中存储多少位数字和多少位小数。
不幸的是,我不知道如何在 VB.Net 中检查这一点。
The
F
andN
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.