我如何使用.NET现有创建一个新的VFP(OLEDB)表? [英] How do I create a new VFP (OLEDB) table from an existing one using .NET?

查看:137
本文介绍了我如何使用.NET现有创建一个新的VFP(OLEDB)表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们必须创建一个数字的Visual FoxPro(DBF)表的应用程序。其中每个表都有一个不同的模式,但都包含已知日期字段。

We have an application that creates a number of Visual Foxpro (DBF) tables. Each of those tables have a different schema, but they all contain a known date field.

我被要求创建另一个应用程序(在C#),将复制上周的身价从每个表的新表的数据(在不同的文件夹中源表)。鲜明表将保持(例如,如果有三个源表,将有三个目标表)。

I've been asked to create another application (in C#) that will copy the last week's worth of data from each table to a new table (in a different folder to the source tables). The distinct tables will remain (e.g. if there are three source tables, there will be three destination tables).

随着时间的表可能会发生变化(增加如新字段),所以我不能对表结构(除了前面提到的日期字段的存在)的假定。

Over time the tables may change (e.g. new fields added), so I can't make assumptions about table structure (apart from the existence of the aforementioned date field).

什么是从一个表获取数据的最简单/最佳方法并创建具有相同结构的新表?

What's the easiest/best way to take the data from one table and create a new table with the same structure?

我知道如何查询表来提取数据(如填充上周的记录数据集)。然而,我想必须有创建新表并用结果填充它比手动解析架构中的所有字段信息并用它来重新创建目标表的更好的方法。

I know how to query the tables to extract the data (e.g. fill a DataSet with the last week's records). However, I'm thinking there must be a better way of creating a new table and filling it with the results than manually parsing all the field information in the schema and using that to recreate the the destination table.

与FoxPro工作似乎是从SQL Server足够的不同让我头疼的每一轮,所以我需要在我的方法的指导。

Working with FoxPro seems to be different enough from SQL Server to give me a headache at each turn, so I need some guidance on my approach.

生产机上安装了该VFP 9 OLEDB驱动程序。如果可能的话,我们不希望有其他安装了。

The production machine has the VFP 9 OLEDB driver installed on it. If possible, we'd prefer not to have to install much else.

推荐答案

中的数据,以获得精确的副本,表和记录,您可以通过一个单独的SQL - 选择通过

To get an exact copy of the data, table, and records, you can do via a single SQL-Select via

OleDbConnection oConn = new OleDbConnection("Provider=VFPOLEDB.1;Data Source=C:\\SomePath");
OleDbCommand oCmd = new OleDbCommand();
oCmd.Connection = oConn;
oCmd.Connection.Open();
oCmd.CommandText = "select * from SomeTable where someCondition into table YourNewTable";
oCmd.ExecuteNonQuery();         
oConn.Close();

您where子句几乎可以是任何东西,而到表子句告诉VFP引擎打造的结果作为新的表,所以没有必要从一个显式声明的类型,柱等,查询数据和推到另一个...

Your where clause could be almost anything, and the Into TABLE clause tells the VFP engine to create the result set AS A NEW TABLE, so no need to explicitly declare types, columns, etc, query data from one and push into another...

考虑的一个问题.. 。验证用户接入显然能够创建,读取,写入,无论你正在试图创建新表。你甚至可以指定一个完全合格的路径,如C:\SomeOtherPath\Monthly\MyTable1如果需要的话...

One issue of consideration... Verify the user access to obviously be able to create, read, write wherever you are trying to create the new table. You can even specify a fully qualified path, such as C:\SomeOtherPath\Monthly\MyTable1 if need be...

这篇关于我如何使用.NET现有创建一个新的VFP(OLEDB)表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆