[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

dbf structure by using .net

Robin Prosch via .NET 247

3/31/2005 11:36:00 AM

Dear friends
i am trying to get the table structur of dbf file by using odbc connection source of ado.net
but i am not be able to get the structure of dbf file
--------------------------------
From: ritesh Modi

-----------------------
Posted by a user from .NET 247 (http://www.dotn...)

<Id>+wwBTI2DsEWm66qYaIuRew==</Id>
2 Answers

Paul Clement

3/31/2005 4:41:00 PM

0

On Thu, 31 Mar 2005 03:36:15 -0800, ritesh Modi via .NET 247 <anonymous@dotnet247.com> wrote:

&#164; Dear friends
&#164; i am trying to get the table structur of dbf file by using odbc connection source of ado.net
&#164; but i am not be able to get the structure of dbf file

Could you be a bit more specific? Are you trying to determine the schema (columns and related info)
in the database?


Paul
~~~~
Microsoft MVP (Visual Basic)

Cindy Winegarden

4/3/2005 8:32:00 PM

0

Hi Ritesh,

First off, why don''t you use the FoxPro and Visual FoxPro OLE DB data
provider? It''s downloadable from
http://msdn.microsoft.com/vfoxpro/downloa... .

The following code works for me (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=VFPOLEDB.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(CommandBehavior.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").ToString() & "." & _
row.Item("BaseColumnName").ToString())
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...


"ritesh Modi via .NET 247" <anonymous@dotnet247.com> wrote in message
news:OvzzZXeNFHA.4052@TK2MSFTNGP12.phx.gbl...
> Dear friends
> i am trying to get the table structur of dbf file by using odbc connection
> source of ado.net
> but i am not be able to get the structure of dbf file
> --------------------------------
> From: ritesh Modi