.NET创建FoxPro DBF文件

1.安装FoxPro OleDb Provider.下载地址如下

http://www.microsoft.com/downloads/details.aspx?FamilyID=e1a87d8f-2d58-491f-a0fa-95a3289c5fd4&DisplayLang=en

2.代码如下

string ole_connstring = @"Provider=VFPOLEDB.1;Data Source=D:/dbfdata;";
            OleDbConnection ole_conn = new OleDbConnection(ole_connstring);
            ole_conn.Open();

            OleDbCommand cmd1 = new OleDbCommand("Create Table TestTable (Field1 int, Field2 char(10))", ole_conn);

            OleDbCommand cmd2 = new OleDbCommand("Insert Into TestTable values (1,'Hello3')", ole_conn);
            OleDbCommand cmd3 = new OleDbCommand("Insert Into TestTable values (2,'Hello4')", ole_conn);
            cmd1.ExecuteNonQuery();
            cmd2.ExecuteNonQuery();
            cmd3.ExecuteNonQuery();

            ole_conn.Close();

你可能感兴趣的:(.NET创建FoxPro DBF文件)