Open FoxPro spreadsheet in VB.net 2005

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

But ... I only need to get the column names. I do not need to choose anything. I am trying to dynamically browse all of our free tables and tune the list of each column from each file and xref to another free table containing a description of each column.

I have a working model now, but it requires me to ...

SELECT TOP 1 FROM "File" ORDER BY 1 

But on the largest table, it only takes two minutes to read in the first record, and there are more than 250 tables. In general, it takes 15 to 20 minutes.

Or is there another way to get the first record of a table without using "ORDER BY"?

Here is what I still have. The "file" is passed as a parameter.
It will contain information 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) 

Then I take datatable (dt) and scroll to get the column information.

I would like it to be as fast as Visual Studio when I create a dataset and load all the tables from the directory through the wizard. He can very quickly find all the information about the columns without reading the data from the table.

Let me know if you need more information.

Thanks.

+4
source share
2 answers

Why do you need to record any recordings at all? You should be able to say:

 SELECT * FROM "File" where 1 = 0 

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

You can also look at the GetOleDbSchemaTable method on the OleDbConnection class , as it will allow you to get information about the database schema without having to execute a query.

You can also use Microsoft ADO Extensions for the definition language and data security through the COM interface (mxADOX.dll) to get schema information as well.

+6
source

I have not tried this. But that seems to be the way to go.

In particular, the GetSchema method in the OleDbConnection instance. http://msdn.microsoft.com/en-us/library/ms254934(VS.80).aspx

+1
source

All Articles