从访问数据库中选择所有表格。 [英] Selecting all tabels from an access db.
本文介绍了从访问数据库中选择所有表格。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我想在我的应用程序中加载各种访问数据库,但我不能确定如何获取所有表格从数据库到我的数据集。
数据库都不同,所以我不知道任何表的名称。
任何有关如何解决这个问题的帮助将不胜感激!
-
Lasse
Hello,
I would like to load various access databases in my application, but I can''t
figure out how to get all tabels from the database into my dataset.
The databases are all different, so I don''t know the names of any tables.
Any help on how to solve this would be greatly appreciated!
--
Lasse
推荐答案
取决于你的数据库。可以使用
系统表找到访问中的表名。
SELECT MSysObjects.Name
FROM MSysObjects
WHERE(((MSysObjects.Name)Not Like" MSys *")AND((MSysObjects.Type)= 1
Or(MSysObjects.Type)= 6))
ORDER BY MSysObjects.Name;
-
OHM(Terry Burns)
。 。 。单手人。 。
当你不知道自己在做什么时,过得很快
" Lasse Eskildsen" <乐****************** @ webspeed.dk>在消息中写道
新闻:ez ************* @ TK2MSFTNGP10.phx.gbl ...
Depends on your databale. Table names in access can be found using the
system table.
SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Name) Not Like "MSys*") AND ((MSysObjects.Type)=1
Or (MSysObjects.Type)=6))
ORDER BY MSysObjects.Name;
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don''t know what you''re doing
"Lasse Eskildsen" <Le******************@webspeed.dk> wrote in message
news:ez*************@TK2MSFTNGP10.phx.gbl...
你好,
我想在我的应用程序中加载各种访问数据库,但是我不知道如何将数据库中的所有表格都放到我的数据集中。
数据库各种不同,所以我不知道任何桌子的名称。
任何有关如何解决这个问题的帮助将不胜感激!
- > Lasse
Hello,
I would like to load various access databases in my application, but I can''t figure out how to get all tabels from the database into my dataset.
The databases are all different, so I don''t know the names of any tables.
Any help on how to solve this would be greatly appreciated!
--
Lasse
另一种方法。
昏暗的strConn As String
Dim conn As OleDbConnection
strConn =" Provider = Microsoft.Jet.OLEDB.4.0;"
strConn& ="数据源= Northwind.mdb;"
conn =新OleDbConnection(strConn)
conn.Open()
Dim dtTableNames作为DataTable
dttablenames = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tabl es,_
New Object(){Nothing,Nothing,Nothing," TABLE"}}
conn.Close()
Dim dr As DataRow
For each dr in dtTableNames.Rows
Trace.WriteLine( dr.Item(TABLE_NAME))
下一页
肯
- --------------------
" Lasse Eskildsen" <乐****************** @ webspeed.dk>在消息中写道
新闻:ez ************* @ TK2MSFTNGP10.phx.gbl ...
您好,
我想在我的应用程序中加载各种访问数据库,但我不能确定如何将数据库中的所有表格都加载到我的数据集中。 />
数据库都是不同的,所以我不知道任何表的名称。
如何解决这个问题的任何帮助都将是非常感谢!
-
Lasse
Hi,
Another method.
Dim strConn As String
Dim conn As OleDbConnection
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Northwind.mdb;"
conn = New OleDbConnection(strConn)
conn.Open()
Dim dtTableNames As DataTable
dttablenames = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _
New Object() {Nothing, Nothing, Nothing, "TABLE"})
conn.Close()
Dim dr As DataRow
For Each dr In dtTableNames.Rows
Trace.WriteLine(dr.Item("TABLE_NAME"))
Next
Ken
----------------------
"Lasse Eskildsen" <Le******************@webspeed.dk> wrote in message
news:ez*************@TK2MSFTNGP10.phx.gbl...
Hello,
I would like to load various access databases in my application, but I can''t
figure out how to get all tabels from the database into my dataset.
The databases are all different, so I don''t know the names of any tables.
Any help on how to solve this would be greatly appreciated!
--
Lasse
On Sun,7月25日2004 17:49:52 +0100,One Handed Man \(OHM - Terry Burns \) < news.microsoft.com>
写道:
$ b $b¤取决于您的数据库。可以使用
$ b $b¤系统表找到访问中的表名。
$ b $b¤
$ b $b¤SELECTMSysObjects.Name
¤来自MSysObjects
$ b $b¤WHERE(((MSysObjects.Name)不喜欢" MSys *")AND((MSysObjects.Type)= 1
$ b $b¤Or(或MSysObjects.Type)= 6))
$ b $b¤ORDERBY MSysObjects.Name;
只是一个FYI,Access系统表通常是安全的,因此无法访问它们。使用模式
方法更可取。
Paul ~~~ pc ** ****@ameritech.net
Microsoft MVP(Visual Basic)
On Sun, 25 Jul 2004 17:49:52 +0100, "One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com>
wrote:
¤ Depends on your databale. Table names in access can be found using the
¤ system table.
¤
¤ SELECT MSysObjects.Name
¤ FROM MSysObjects
¤ WHERE (((MSysObjects.Name) Not Like "MSys*") AND ((MSysObjects.Type)=1
¤ Or (MSysObjects.Type)=6))
¤ ORDER BY MSysObjects.Name;
Just an FYI, Access system tables are typically secured so they cannot be accessed. Using the schema
method is preferable.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
这篇关于从访问数据库中选择所有表格。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文