Random Dev Notes

June 2, 2013

Creating Visual FoxPro Tables and database container from DataTables

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

While working on the Visual FoxPro Entity Framework Provider I found myself in a position where I needed to convert schema DataTables into dbfs so that they could be queried.  So I created a class that would encapsulate the logic needed to convert DataTables into dbfs with a database container.  This blog entry shows how to use DataTableDbcCreator to create VFP tables and database container.

Here is an example:
   1:  using (var connection = new VfpConnection(ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString)) {
   2:      connection.Open();
   3:   
   4:      var tables = connection.GetSchema(VfpConnection.SchemaNames.Tables);
   5:      var fields = connection.GetSchema(VfpConnection.SchemaNames.TableFields);
   6:   
   7:      connection.Close();
   8:   
   9:      var dbc = GetNewDbcFullPath();
  10:      var dbcCreator = new DataTableDbcCreator(dbc);
  11:   
  12:      dbcCreator.Add(tables);
  13:      dbcCreator.Add(fields);
  14:  }

This is what was created:
image


* Example code can be found in Visual FoxPro .Net Examples.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: