在 VB.net 2005 中打开 FoxPro 表

发布于 2024-07-11 22:08:34 字数 1207 浏览 6 评论 0 原文

我需要使用 oledb 连接在 vb.net 中打开 Foxpro 空闲表。

但是......我只需要获取列名。 我真的不需要“选择”任何东西。 我试图动态浏览所有可用表,并设置每个文件中每列的列表,并将其外部引用到另一个包含每列描述的可用表。

我现在有一个工作模型,但它要求我这样做...

SELECT TOP 1 FROM "File" ORDER BY 1

但是在最大的表上,仅读取第一条记录就需要两分钟多的时间,并且有超过 250 个表。 总的来说,需要 15 到 20 分钟。

或者,是否有另一种方法可以只获取表的第一条记录而不使用“ORDER BY”?

这是我到目前为止所拥有的。 “文件”作为参数传入。
它将包含类似“C:\data\table1.dbf”的信息,

Dim filePath As String
filePath = IO.Path.GetDirectoryName(file)
myOledbConnection = New OleDbConnection("Provider=VFPOLEDB.1;Data Source=" & filePath & ";Collating Sequence=MACHINE")
myOledbCommand = New OleDbCommand
myOledbDataAdapter = New OleDbDataAdapter
Dim fields, from, order As String

fields = "select top 1 *"
from = " from " & file
order = " order by 1"

myOledbCommand.CommandText = fields & from & order
myOledbCommand.Connection = myOledbConnection

myOledbDataAdapter.SelectCommand = myOledbCommand
myOledbDataAdapter.Fill(dt)                     

然后我获取数据表(dt)并循环以获取列信息。

当我创建数据集并通过向导从目录加载所有表时,我希望它能像 Visual Studio 一样快。 它能够非常快速地找到所有列信息,而无需从表中读取数据。

如果您需要更多信息,请与我们联系。

谢谢。

I need to open foxpro free tables in vb.net using the oledb connection.

But... I only need to get the column names. I don't really need to 'select' anything.
I am trying to dynamically browse through all our free tables and set up a listing of every column from every file and xref that to another free table that contains a description of each column.

I have a working model now, but it requires that I do...

SELECT TOP 1 FROM "File" ORDER BY 1

But on the largest table, it takes over two minutes just to read in the first record and there are over 250 tables. Overall, it takes between 15 and 20 minutes.

Or, is there another way to only get the first record of the table without using 'ORDER BY'?

Here's what I have so far. "File" is passed in as a parameter.
It would contain info like "C:\data\table1.dbf"

Dim filePath As String
filePath = IO.Path.GetDirectoryName(file)
myOledbConnection = New OleDbConnection("Provider=VFPOLEDB.1;Data Source=" & filePath & ";Collating Sequence=MACHINE")
myOledbCommand = New OleDbCommand
myOledbDataAdapter = New OleDbDataAdapter
Dim fields, from, order As String

fields = "select top 1 *"
from = " from " & file
order = " order by 1"

myOledbCommand.CommandText = fields & from & order
myOledbCommand.Connection = myOledbConnection

myOledbDataAdapter.SelectCommand = myOledbCommand
myOledbDataAdapter.Fill(dt)                     

I then take the datatable (dt) and loop through to get the column information.

I would like it to be as quick as Visual Studio is when I create a dataset and load all tables from the directory through the wizard. It is able to very quickly find all the column information without reading in the data from the table.

Let me know if you need more information.

Thanks.

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

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

发布评论

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

评论(2

暖伴 2024-07-18 22:08:34

为什么您需要获取任何记录? 您应该能够说:

SELECT * FROM "File" where 1 = 0

这将为您提供一个空结果集,还将为您提供有关返回的投影的元数据。

您可能还想查看 GetOleDbSchemaTable 方法 >OleDbConnection 类,因为它将允许您获取有关数据库架构的信息,而无需执行查询。

您还可以使用 Microsoft ADO 数据定义语言和安全扩展 还通过 COM 互操作 (mxADOX.dll) 获取架构信息。

Why do you need to get any records at all? You should be able to say:

SELECT * FROM "File" where 1 = 0

This will give you an empty result set, will also give you metadata on the projection returned.

You might also want to look into the GetOleDbSchemaTable method on the OleDbConnection class, as it will allow you to get information about the schema of the database without having to perform a query.

You can also use the Microsoft ADO Extensions for Data Definition Language and Security through COM interop (mxADOX.dll) to get the schema information as well.

守不住的情 2024-07-18 22:08:34

我没试过这个/。 但是,这看起来像是要走的路。

特别是 OleDbConnection 实例上的“GetSchema”方法。
http://msdn.microsoft.com/en-us /library/ms254934(VS.80).aspx

I have not tried this/. But, it looks like the way to go.

Specifically the "GetSchema" method on OleDbConnection instance.
http://msdn.microsoft.com/en-us/library/ms254934(VS.80).aspx

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