Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.odbcnet
How can I display the table names and field names in FoxPro 2.06 using Visual Basic.net
Robin Prosch via .NET 247
6/8/2005 5:00:00 AM
I need to display table names and field names for each table in FoxPro 2.06 from my project using ODBC.I am working in VB .Net.
I found following functions to display the desired results
'Display Tables' and
'Display Structure'
But when i run them from my project i get an error.
What are the SQL queries for this problem?
--------------------------------
From: Nida Ahmad
-----------------------
Posted by a user from .NET 247 (
http://www.dotn...
)
<Id>ddUcY3pCEUuEf7juWAjtmw==</Id>
1 Answer
Cindy Winegarden
6/9/2005 10:34:00 PM
0
Hi Nida,
Display Tables and Display Structure are XBase commands that aren''t
supported by the FoxPro ODBC drivers and OLE DB data provider.
Since you''re working with FoxPro 2.6 "free" tables (not belonging to a VFP
DBC) you can use Directory.GetFiles() for a list of the DBFs in the
directory.
Here''s code I posted earlier on how to get table structures:
''-- (adapted from a post by David Sceppa of Microsoft)
''-- Begin code
Imports System.Data
Imports System.Data.OleDb
Module Module1
Sub Main()
Try
Dim cn As New OleDbConnection("Provider=VFPO­LEDB.1;Data Source
=
""C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO
9\SAMPLES\NORTHWIND\NORTHWIND.­DBC"";")
cn.Open()
Dim cmd As IDbCommand = cn.CreateCommand
cmd.CommandText = "Select * From Customers"
Dim rdr As IDataReader
rdr = cmd.ExecuteReader(CommandBehav­ior.SchemaOnly Or
CommandBehavior.KeyInfo)
Dim tbl As DataTable = rdr.GetSchemaTable
Console.WriteLine("ColumnName" & vbTab & "IsKey" & vbTab &
"BaseTableName.BaseColumnName"­)
Dim row As DataRow
For Each row In tbl.Rows
Console.WriteLine(row.Item( _
"ColumnName").ToString() & vbTab & _
row.Item("IsKey").ToString() & vbTab & _
row.Item("BaseTableName").ToSt­ring() & "." & _
row.Item("BaseColumnName").ToS­tring())
Next
Catch e As Exception
Stop
End Try
End Sub
End Module
''-- End code
You can get the details of what the various colums represent from the
GetSchemaTable topic in Help.
--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
cindy_winegarden@msn.com www.cindywinegarden.com
Blog:
http://spaces.msn.com/members/cindy...
"Nida Ahmad via .NET 247" <anonymous@dotnet247.com> wrote in message
news:Obrifb%23aFHA.3184@TK2MSFTNGP15.phx.gbl...
>I need to display table names and field names for each table in FoxPro 2.06
>from my project using ODBC.I am working in VB .Net.
> I found following functions to display the desired results
> ''Display Tables'' and
> ''Display Structure''
> But when i run them from my project i get an error.
>
> What are the SQL queries for this problem?
>
>
>
>
>
> --------------------------------
> From: Nida Ahmad
>
> -----------------------
> Posted by a user from .NET 247 (
http://www.dotn...
)
>
> <Id>ddUcY3pCEUuEf7juWAjtmw==</Id>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
How can I display the table names and field names in FoxPro 2.06 using Visual Basic.net
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password