如何使用oledb命令获取MS-Access数据库表数据类型? [英] How to get MS-Access database table data type using oledb command?

查看:76
本文介绍了如何使用oledb命令获取MS-Access数据库表数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想使用oledb命令(即oledb查询)来获取ms-access数据库表列的数据类型,但我不知道.请帮帮我.

在此先感谢!!

Hello Everyone,
I want to get ms-access database table columns data types using with oledb command(that is oledb query) but I don''t have an idea. Please help me.

Thanks in advance!!

推荐答案

据我所知,获取表列信息的唯一方法是Access中的TableDefs.如果您有权访问系统表,则可以获取有关表是什么的信息.因此,要获取此信息,需要在VBA中进行编程.
From what I know the only way to get table column information is the TableDefs within Access. You can get information about what the tables are if you have access to the system tables. So to get this information, need to program in VBA.


要找出Access表中每个字段的数据类型,可以使用DAO或ADOX.
To find out the data type of each field in an Access table, you can use DAO or ADOX.
Private Sub TableDefDao()

Dim db As DAO.Database
Set db = DAO.OpenDatabase("C:\Users\Julien\Documents\Database2.mdb")

Dim t As DAO.TableDef
Dim f As DAO.Field
For Each t In db.TableDefs
Debug.Print t.Name
    For Each f In t.Fields
        Debug.Print vbTab & f.Name & vbTab & f.Type
    Next
Next
End Sub



在VB中,您可以从followinf网站转换为c#-
http://converter.telerik.com/ [ ^ ]



it''s in VB you can convert to c# from followinf site-
http://converter.telerik.com/[^]


这篇关于如何使用oledb命令获取MS-Access数据库表数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆