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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:10:56+00:00 2026-06-13T00:10:56+00:00

Having problems with Visual Fox Pro ODBC drivers (and OLE DB) the code I’m

  • 0

Having problems with Visual Fox Pro ODBC drivers (and OLE DB) the code I’m using to dynamically get all the column names for a DBF table works fine for small datasets. But if I try getting the table schema using the below code for a large table then it can take 60 seconds to get the schema.

OdbcConnection conn = new OdbcConnection(@"Dsn=Boss;sourcedb=u:\32BITBOSS\DATA;sourcetype=DBF;exclusive=No;backgroundfetch=Yes;collate=Machine;null=Yes;deleted=Yes");     
OdbcCommand cmd = new OdbcCommand("Select * from " + listBox1.SelectedItem.ToString(), conn);
conn.Open();
try
{

    OdbcDataReader reader = cmd.ExecuteReader();
    DataTable dt = reader.GetSchemaTable();

    listBox2.Items.Clear();

    foreach (DataRow row in dt.Rows)
    {
        listBox2.Items.Add(row[0].ToString());
    }

    conn.Close();

}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
    conn.Close();
}

Now I get that this is due to the Select command dragging all 500,000 records or so into the data reader before it can then extract the column names. But visual fox pro is pretty rubbish at limiting the record return.

I ideally want to limit the return to just 1 record, but on the assumption I don’t know any of the column names to utilise a WHERE clause this doesn’t work.

VFP can utilise the TOP SQL command, but to do that you need an ORDER BY to go with it, and since I don’t have the any of the column names to utilise, this doesn’t work either.

So am a bit stumped trying to think of a clever way to dynamically get the table schema without the slow down in VFP.

I don’t think database conversions on the fly will be any faster. Anyone got any clever ideas (apart from changing the database system, it’s inherited in the job and I currently have to work with it 🙂 )?

  • 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-13T00:10:58+00:00Added an answer on June 13, 2026 at 12:10 am

    Change this line:

    OdbcCommand cmd = new OdbcCommand("Select * from " + listBox1.SelectedItem.ToString(), conn); 
    

    To this line:

    OdbcCommand cmd = new OdbcCommand(string.Format("Select * from {0} where 1 = 0", listBox1.SelectedItem.ToString()), conn); 
    

    This will bring back zero records, but fill the schema. Now that you have the schema you can build a filter further.

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

Sidebar

Related Questions

I'm using the latest Qt SDK (2.4.0) and am having problems getting the visual
I'm having all kinds of problems getting Visual Studio 2010 to work with the
I am having problems using the Visual Studio 2008 Javascript debugger. I can’t set
I'm having problems with Visual Studio 2008, namely, syntax-highlighting and intellisense for *.aspx, *.js
I'm having problems installing SQL Server as prerequisite on my Visual Studio Setup application
I just installed Visual Studio 2010 on a new computer and am having problems
I have been having these really odd problems with Visual Studio 2010. At this
I'm building a Visual Studio-like application in WPF and I'm having some problems identifying
I'm trying to build firefox but I'm having some problems. I currently have Visual
I'm having the following problem using the Visual Studio 2010 Team System Beta 1:

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.