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 3352512
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:02:21+00:00 2026-05-18T02:02:21+00:00

Question: I am working with existing commercial MS Visual Foxpro application, and need to

  • 0

Question:

I am working with existing commercial MS Visual Foxpro application, and need to extract data from the database directly using a c# application. Unfortunately, not all of the tables are stored in the same database, some of the records are stored in a database broken down by year. How do I create a query against these two databases using a single join?

I am using Microsoft’s OLE DB Provider for Visual FoxPro 9.0 (SP2)

More Detail:

Essentially, the customer information is stored in one database, and the customer purchase history is stored a database broken down by year. So I am trying to create a simple query to print out customers and their most recent purchase from this year.

In graphical form, the file structure of the db looks like this:

Data\
 +-2009\
 |  +-MyDB.dbc
 |  +-Sales.dbf
 +-2010\
 |  +-MyDB.dbc
 |  +-Sales.dbf
 +-MyDB.dbc
 +-Customers.dbf

Currently I can connect to each DB individually, and query them:

// This works to connect to the customer DB
string connectionPath1 = @"Provider=vfpoledb.1;Data Source=E:\Data\MyDB.dbc";
OleDbConnection conn1 = new OleDbConnection(connectionPath1);
OleDbCommand command1 = new OleDbCommand(@"SELECT * FROM Customers", conn1);
OleDbDataReader reader1 = command1.ExecuteReader();

// This works to connect to the annual sales record DB
string connectionPath2 = @"Provider=vfpoledb.1;Data Source=E:\Data\2010\MyDB.dbc";
OleDbConnection conn2 = new OleDbConnection(connectionPath2);
OleDbCommand command2 = new OleDbCommand(@"SELECT * FROM Sales", conn2);
OleDbDataReader reader2 = command2.ExecuteReader();

What I can’t do is execute my join statement:

//How do I do this?
OleDbConnection connMagic = new OleDbConnection(connectionPath1, connectionPath2); //non-valid code
OleDbCommand commandIWant = new OleDbCommand(@"SELECT Customers.Name, Sales.Item, Sales.Date FROM Customers LEFT JOIN Sales ON (Customers.ID=Sales.CustomerID)", connMagic);
OleDbDataReader reader3 = commandIWant.ExecuteReader();
  • 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-05-18T02:02:22+00:00Added an answer on May 18, 2026 at 2:02 am

    If the directory structure is as you indicate… where the different years are all UNDER the parent common, you can query to all of them directly just by including the relative path…

    select 
          a1.Whatever,
          b1.Sales1
       from
          Customers a1,
          2009\Sales b1
       where 
          a1.CustomerID = b1.CustomerID
    union all
    select 
          a1.Whatever,
          b1.Sales1
       from
          Customers a1,
          2010\Sales b1
       where 
          a1.CustomerID = b1.CustomerID
    union ... 
    

    you dont even have to qualify the actual DBC either, the OleDB should auto-detect it, but having it included wouldn’t hurt as your original samples indicate…

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

Sidebar

Related Questions

Question: How do you write data to an already existing file at the beginning
I am working to configure Spring-Security with an existing application, for just basic security
I'm working on a database upgrader application. The upgrader updates the schema of a
Just a question about best-practices when upgrading an existing database. Assuming there will be
I'm currently working on building an application in CakePHP. There's a quite extensive existing
I am currently working on converting an existing web application to support an additional
I'm working on implementing dynamic loading of Pages into a existing Silverlight application. So
I have a question about the design of an application I'm working on. I
I'm working on embedding Python 2.6 into an existing c++ application. So far I
I am working on a program that loads and saves data from text files,

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.