关闭

.NET读取foxpro dbf文件

1117人阅读 评论(0) 收藏 举报

首先,从微软网站下载odbc_net.msi,VFPODBC.msi,并且安装。代码如下:

DataSet ds = new DataSet();

string dbf_connstring = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=d:/dbfata;Exclusive=No;Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO";//其中d:/dbfdata为你的foxpro dbf文件夹。

OdbcDataAdapter odbcAdapter = new OdbcDataAdapter();
   Console.WriteLine("DBF Connection ready...");
   OdbcConnection dbf_conn = new OdbcConnection(dbf_connstring);
   try
   {
    dbf_conn.Open();
    Console.WriteLine("DBF Connection ok...");
   }
   catch(Exception e1)
   {
    Console.WriteLine("DBF Connection fail...");
    Console.WriteLine(e1.Message);
   }
   Console.WriteLine("Query Info...");
   dbf_sql = "select wip_no as wo_no,wip_line as wo_seq,item_no as model,create_dat as create_date,plan_qty as wo_qty,make_qty as complete_qty,wip_type as wo_type from wip_header";
   odbcAdapter = new OdbcDataAdapter(dbf_sql,dbf_conn);
   try
   {
    odbcAdapter.Fill(ds);
   }
   catch(Exception e2)
   {
    Console.WriteLine(e2.Message);
   }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:241878次
    • 积分:3541
    • 等级:
    • 排名:第9338名
    • 原创:102篇
    • 转载:2篇
    • 译文:0篇
    • 评论:96条
    文章分类
    最新评论