Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8466843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:27:47+00:00 2026-06-10T15:27:47+00:00

How does one list the primary keys of a table in Fox Pro with

  • 0

How does one list the primary keys of a table in Fox Pro with the OLE DB Provider?

Using C# and switching my build to x86 instead of x64 I was able to use oledb provider for Fox Pro to display some information about the table:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;

namespace obtainFoxSchema
{
    class Program
    {
        static void Main(string[] args)
        {
            OleDbConnection connection = new OleDbConnection(
                "Provider=VFPOLEDB.1;Data Source=X:\\FREETABLES\\DATA;"
            );
            connection.Open();
            DataTable tables = connection.GetSchema(
                System.Data.OleDb.OleDbMetaDataCollectionNames.Tables
            );

            foreach (System.Data.DataRow rowTables in tables.Rows)
            {
                Console.Out.WriteLine(rowTables["table_name"].ToString());
                DataTable columns = connection.GetSchema(
                    System.Data.OleDb.OleDbMetaDataCollectionNames.Columns,
                    new String[] { null, null, rowTables["table_name"].ToString(), null }
                );
                foreach (System.Data.DataRow rowColumns in columns.Rows)
                {
                    Console.Out.WriteLine(
                        rowTables["table_name"].ToString() + "." +
                        rowColumns["column_name"].ToString() + " = " +
                        rowColumns["data_type"].ToString()
                    );
                }
            }
            Console.Out.WriteLine("stop");
        }
    }
}

But I really don’t know where to look in the objects returned to find the primary keys or the foreign keys between tables.

Any ideas where that kind of thing might be?

And yes I found the code for this in another question, but I built the connection string myself using Excel 2007’s Get External Data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:27:48+00:00Added an answer on June 10, 2026 at 3:27 pm

    I saw your post on Twitter. I am answering this question as a VFP developer with very little experience in Visual Studio and C#.

    Not sure if you need things programmatically or just need to get the details. Have you tried to add the database to the Server Explorer? According to the Visual FoxPro Help File…

    To connect to a Visual FoxPro database or table through the Visual FoxPro OLE DB Provider
    Open Visual Studio.

    1. From the View menu, select Server Explorer.
    2. In the Server Explorer pane, right-click Data Connections, and click Add Connection
    3. In the Data Link Properties dialog box, click the Provider tab.
    4. Select Microsoft OLE DB Provider for Visual FoxPro.
    5. The Connection tab in the Data Link Properties dialog box appears.

    If this is not helpful, there is a DDEX provider, but it might only work with a specific version of Visual Studio.

    http://vfpx.codeplex.com/wikipage?title=Sedna&referringTitle=Home#DDEX

    If you are using the Entity Framework, there is a provider:

    http://vfpefprovider.codeplex.com/

    Rick

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one alternate row colors in a table in django that's generated using
How does Seam Framework handle composite primary keys in pages.xml using EntityHome? The usual
Given a list of numbers, how does one find differences between every ( i
I have a list where one thread just does push_back and other thread occasionally
I have two tables. One contains a list of products with the primary key
How does one change the background color of a Java AWT List item? By
How does one filter a list of records to remove those that have some
does one perform better over the other in terms of indexing/quering etc ? e.g.
How does one wait until all of the Javascript is loaded before curling a
How does one implement a multithreaded single process model in linux fedora under c

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.