Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Obtain table names in VFP database
Message
From
28/11/2006 10:23:44
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01172879
Message ID:
01172940
Views:
15
This message has been marked as the solution to the initial question of the thread.
>I have a oledb connection to vfp database from net project. I need tables name list of vfp database and fields of any selected table of this database. How can I obtain this information by oledb connection.
>
>I use this command if I connect to sqlserver.
>"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES Where OBJECTPROPERTY(object_id(TABLE_NAME), N'IsUserTable')=1"
>
>
>thanks in advance

Ali,
Information_schema.tables and such are views of SQL2000 (which are replaced by new system management views in SQL2005).
You can use OleDbConnection.GetSchema() to query schema information. Here is a sample getting partial info:
using System;
using System.Data;
using System.Data.OleDb;

class VFPDatabaseDiscovery
{
 static void Main()
 {
   string strCon =
      @"Provider=vfpoledb;Data Source=C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 9\SAMPLES\data\testdata.dbc";
   OleDbConnection con = new OleDbConnection(strCon);
   con.Open();

   DataTable tables  = con.GetSchema("Tables");
   DataTable views   = con.GetSchema("Views");
   DataTable columns = con.GetSchema("Columns");
   con.Close();

   Console.WriteLine("Tables in catalog:");
   foreach (DataRow row in tables.Rows)
   {
      Console.WriteLine(row["table_name"]);
   }
   Console.WriteLine("Views in catalog:");
   foreach (DataRow row in views.Rows)
   {
      Console.WriteLine(row["table_name"]);
   }
   Console.WriteLine("Column info in catalog:");
   foreach (DataRow row in columns.Rows)
   {
      Console.WriteLine("{0}.{1}",row["table_name"],row["column_name"]);
   }
 }
}
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform