C# 创建DBF文件
string str_oleConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=dBASE IV;";
System.Data.OleDb.OleDbConnection ole_conn = new System.Data.OleDb.OleDbConnection(str_oleConn);
try
{
ole_conn.Open();
System.Data.OleDb.OleDbCommand cmd1 = new System.Data.OleDb.OleDbCommand
("Create Table xxx (Field1 int, Field2 char(10))",
ole_conn);
System.Data.OleDb.OleDbCommand cmd2 = new System.Data.OleDb.OleDbCommand
("Insert Into xxx values (1,'Hello3')", ole_conn);
System.Data.OleDb.OleDbCommand cmd3 = new System.Data.OleDb.OleDbCommand
("Insert Into xxx values (2,'Hello4')", ole_conn);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
cmd3.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
ole_conn.Close();
}
System.Data.OleDb.OleDbConnection ole_conn = new System.Data.OleDb.OleDbConnection(str_oleConn);
try
{
ole_conn.Open();
System.Data.OleDb.OleDbCommand cmd1 = new System.Data.OleDb.OleDbCommand
("Create Table xxx (Field1 int, Field2 char(10))",
ole_conn);
System.Data.OleDb.OleDbCommand cmd2 = new System.Data.OleDb.OleDbCommand
("Insert Into xxx values (1,'Hello3')", ole_conn);
System.Data.OleDb.OleDbCommand cmd3 = new System.Data.OleDb.OleDbCommand
("Insert Into xxx values (2,'Hello4')", ole_conn);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
cmd3.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
ole_conn.Close();
}