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

前端 未结 3 824
忘了有多久
忘了有多久 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条回答
  •  花落未央
    2021-01-14 05:02

    Try something like this (note written in VB.NET and converted use www.developerfusion.co.uk/tools ):

    using System.Data.OleDb; 
    using System.IO; 
    
    static class Module1 
    { 
        public static void Main() 
        { 
            OleDbConnection oConn = new OleDbConnection("Provider=VFPOLEDB.1;Data Source=C:\\"); 
            OleDbCommand oCmd = new OleDbCommand(); 
    
            { 
                oCmd.Connection = oConn; 
                oCmd.Connection.Open(); 
                // Create a sample FoxPro table 
                oCmd.CommandText = "CREATE TABLE Table1 (FldOne c(10))"; 
                oCmd.CommandType = CommandType.Text; 
                oCmd.ExecuteNonQuery(); 
            } 
    
            oConn.Close(); 
            oConn.Dispose(); 
            oCmd.Dispose(); 
        } 
    } 
    

提交回复
热议问题