首先要下载vpf9.0(/Files/gaoyuchuanIT/vfpoledb.rar),在项目中引用Microsoft OLEDB Provider for Visual FoxPro 7.0 Type Library;

然后连接数据库文件:

     string strConn = "Provider=VFPOLEDB.1;Data Source=" + Server.MapPath("~/Manager/Public/Template") + ";Collating Sequence=MACHINE;";
            OleDbConnection oldcon = new OleDbConnection(strConn);

删除操作比较麻烦,要分两步进行:

   第一步:作删除标记
            cmd.CommandText = "delete from KC中山.dbf";
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            oldcon.Close();

  第二步:执行删除
            oldcon.Open();            
            cmd.CommandText = "pack KC中山.dbf";
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();

追加数据操作:

  insert into KC中山.dbf values('')

posted on 2010-01-28 16:52  游子  阅读(1467)  评论(0编辑  收藏  举报