日期:2014-05-18  浏览次数:21071 次

版主:帮帮忙,C#如何将查询结果输出DBF
我想用c#操作DBF表,将源表的一些查询结果输出到新创建DBF文件,运行显示“OK”,但是找不到输出的dbf表。代码如下:
System.Data.Odbc.OdbcConnection DBFconn = new System.Data.Odbc.OdbcConnection();
string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=D:\" ; string strSQL = "SELECT * FROM dm INTO TABLE E:\\MyDBF.DBF;
  DBFconn.ConnectionString = connStr;
  DBFconn.Open();
  OdbcCommand cmd = new OdbcCommand();
  cmd.Connection = DBFconn;
  cmd.CommandText = strSQL;
  cmd.CommandType = CommandType.Text;
  OdbcTransaction transaction;
  transaction = DBFconn.BeginTransaction();
  try
  {
  cmd.Transaction=transaction;
  cmd.ExecuteNonQuery();
  transaction.Commit();  
  DBFconn.Close();
  MessageBox.Show("OK");
  }
  catch (Exception ex)
  {
  MessageBox.Show(ex.Message);
  }

------解决方案--------------------
参考
http://www.cnblogs.com/tanjy/archive/2006/11/14/560046.html