DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Advantages and Disadvantages of Data Replication in Distributed Databases
  • 5 Key Postgres Advantages Over MySQL
  • Fixing Common Oracle Database Problems
  • SAP HANA Triggers: Enhancing Database Logic and Automation

Trending

  • Subtitles: The Good, the Bad, and the Resource-Heavy
  • Scaling InfluxDB for High-Volume Reporting With Continuous Queries (CQs)
  • Streamlining Event Data in Event-Driven Ansible
  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  1. DZone
  2. Data Engineering
  3. Data
  4. Using Advantage data providers to read DBF-files

Using Advantage data providers to read DBF-files

By 
Gunnar Peipman user avatar
Gunnar Peipman
·
May. 17, 11 · News
Likes (0)
Comment
Save
Tweet
Share
10.1K Views

Join the DZone community and get the full member experience.

Join For Free

In one of my projects I have to read FoxPro DBF-files and import data from them. As this code must run in server and customer doesn’t want to install FoxPro there we found another solution that seems at least to me way better. In this posting I will show you how to read DBF-files using Sybase Advantage data providers.

Getting Advantage data providers

Here are the download links to data providers:

  • Advantage .NET Data Provider Release 10.1 for Windows (32-bit and 64-bit)
  • Platforms for Advantage OLE DB Provider Release 10.1
  • Platforms for Advantage ODBC Driver Release 10.1

I downloaded and installed .NET data provider and my example here is fully based on this.

Configuring application

Advantage Data provider test application

If you run application without configuring some data providers stuff before you will get the following error:

Error 5185: Local server connections are restricted in this environment. See the 5185 error code documentation for details.

Go to your application bin folder and add there usual text file called ads.ini. Here is the content for this file:

[SETTINGS]
MTIER_LOCAL_CONNECTIONS=1

Make sure you add reference to Advantage data provider assembly and include ads.ini to your project like shown on image above.

Getting data to DataTable

Here is short code example about how to get data from DBF-file to DataTable.

static void Main(string[] args)
{
    var tableName = "TABLENAME_WITHOUT_EXTENSION";
 
    var connStr = "data source={0};tabletype=vfp;servertype= local;";
    connStr = string.Format(connStr, "c:\\temp\\");
 
    var table = new DataTable();
 
    using (var conn = new AdsConnection(connStr))           
    using (var adapter = new AdsDataAdapter())
    using (var cmd = new AdsCommand())
    {
        cmd.Connection = conn;
        cmd.CommandText = "select * from " + tableName;
        adapter.SelectCommand = cmd;
 
        conn.Open();
        adapter.Fill(table);
        conn.Close();
    }

    Console.WriteLine("Table fields:");
    foreach (DataColumn col in table.Columns)
        Console.WriteLine(col.ColumnName);
 
    Console.WriteLine(" ");
    Console.WriteLine("Rows: " + table.Rows.Count);
 
    Console.Read();
}

If Advantage data providers were installed correctly and there are no errors in table names, locations and your SQL query then you should see list of table column names and row count on console window when you run the application.

Data (computing) Advantage (cryptography) Database

Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Advantages and Disadvantages of Data Replication in Distributed Databases
  • 5 Key Postgres Advantages Over MySQL
  • Fixing Common Oracle Database Problems
  • SAP HANA Triggers: Enhancing Database Logic and Automation

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!