Random Dev Notes

June 2, 2013

Getting started with VFP Client for ADO.Net

Filed under: .Net Development — Tags: — Tom Brothers @ 9:06 am

VfpClient is simply a wrapper around the System.Data.OleDb classes with the goal of reducing pain points when accessing VFP data from .Net.  Here is a list of some features included in VfpClient:

Getting Started

  • Make sure your project targets x86.  (Requirement when using VfpOleDb provider)
  • Install VfpClient using NuGet
  • Add the VfpClient diagnostics source for tracing command text.
       1:  <?xml version="1.0" encoding="utf-8"?>
       2:  <configuration>
       3:    <system.diagnostics>
       4:      <sources>
       5:        <!-- This source will allow you to see all VFP commands in the Output panel. -->
       6:        <source name="VfpClient" switchValue="Information" >
       7:          <!-- This listener will trace VFP commands to a text file and is intended for use in production when troubleshooting an issue. -->
       8:          <!--<listeners>
       9:            <add name="VfpClientTextWriterTraceListener"
      10:                 type="System.Diagnostics.TextWriterTraceListener"
      11:                 initializeData="c:\VfpClient.txt" />
      12:          </listeners>-->
      13:        </source>
      14:      </sources>
      15:    </system.diagnostics>
      16:    <!-- Need to include the following when using VfpClientTextWriterTraceListener -->
      17:    <!--<trace autoflush="true"/>-->
      18:  </configuration>

  • VfpClient uses the VfpOleDb provider so the VfpOleDb installer is included in the NuGet package in case you don’t already have it installed.  Additionally, the NuGet package includes an installer for VfpClient.  This installer will install the VfpOleDb provider and modify system settings to setup Visual Studio Integration with VfpClient.

* Note:  The installer needs to be run as an Admin.  If you have problems running the install from Windows Explorer then try using the command prompt using “msiexec /i VfpClient.msi”

In Use

All you really need to know to use the VfpClient is that it has equivalent classes that can be found in  the System.Data.OleDb namespace the only difference is that the VfpClient classes have a prefix of “Vfp” instead of “OleDb.”

Here is a simple example using VfpClient:

Visual Studio Integration

The Visual Studio Integration includes some minor changes to simplify the connection process and changed property pages to include VFP specific information.

Here is a view of some of the screens.  The old screen is on the left the new is on the right.

  • Added the "Visual FoxPro Data Client" data source so that you didn’t have to dig through the "<other>" selection.
    image image
  • Simplified the Connection Properties so that you just need to specify a path.
    image image
  • The Schema properties for Table, Fields, Views, and Stored Procedures are VPF specific values (using DBGETPROP).
    image image

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: