How do I create a new VFP (OLEDB) table from an existing one using .NET?

前端 未结 3 859
忘了有多久
忘了有多久 2021-01-14 03:57

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.

I\

3条回答
  •  猫巷女王i
    2021-01-14 04:57

    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();
    

    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...

    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...

提交回复
热议问题