回复网友:wuanzhengxin 数据更新问题(哈!作参考吧)
您的数据库,可能是 vfp的.因为如果 sql_server 的,无法直接拷贝使用假如:您的数据表名叫 ryzlsjb(人员资料数据表),是在一个名叫 ryzlk (人员资料库)数据库之中,
数据库所属的路径是 \\192.168.0.2\e$\ryzl\ (装了 windows server 2003 系统的 E 盘下,文件夹为 ryzl).
那么,用一张表的数据(工作表),去更新另一张表的数据(基础表).该表先做成临时视图再更新,
可以试验如下方式,水平有限,仅供参考吧!
close all
erase sjk.*
create data sjk && 临时随意创建的一个数据库名 sjk
create sql view v_ryzl as select ryzlsjb.序号, ryzlsjb.姓名,ryzlsjb.身份证号, ... ;
from \\192.168.0.2\e$\ryzl\ryzlk!ryzlsjb ORDER BY ryzlsjb.身份证号
thisview="v_ryzl"
DBSetProp(ThisView,"View","SendUpdates",.T.)
DBSetProp(ThisView,"View","BatchUpdateCount",1)
DBSetProp(ThisView,"View","CompareMemo",.T.)
DBSetProp(ThisView,"View","FetchAsNeeded",.F.)
DBSetProp(ThisView,"View","FetchMemo",.T.)
DBSetProp(ThisView,"View","FetchSize",100)
DBSetProp(ThisView,"View","MaxRecords",-1)
DBSetProp(ThisView,"View","Prepared",.F.)
DBSetProp(ThisView,"View","UpdateType",1)
DBSetProp(ThisView,"View","UseMemoSize",255)
DBSetProp(ThisView,"View","Tables","ryzlk!ryzlsjb")
DBSetProp(ThisView,"View","WhereType",3)
DBSetProp(ThisView+".姓名","Field","DataType","C(20)")
DBSetProp(ThisView+".姓名","Field","UpdateName","ryzlk!ryzlsjb.姓名")
DBSetProp(ThisView+".姓名","Field","KeyField",.F.)
DBSetProp(ThisView+".姓名","Field","Updatable",.T.)
DBSetProp(ThisView+".身份证号","Field","DataType","C(20)")
DBSetProp(ThisView+".身份证号","Field","UpdateName","ryzlk!ryzlsjb.身份证号")
DBSetProp(ThisView+".身份证号","Field","KeyField",.T.) && 注意:主索引字段
DBSetProp(ThisView+".身份证号","Field","Updatable",.T.)
....(以此继续共80个字段的属性设置)
close all
open data sjk
sele 1
use v_ryzl
index on 身份证号 to aaa
sele 2
use 工作表名 && 每台终端机用的复制表
index on 身份证号 to bbb
sele 1
update on v_ryzl.身份证号 from 工作表名 replace 字段名1 with 工作表名.字段名1,字段名2 with 工作表名.字段名2,...
close all
return
本例子不需要作连接。如果是 sql_server 数据库表必须作远程连接,按共享方式生成临时视图.
如果您的基础表与工作表的结构是不完全相同的表,但是,存在相同的主索引字段,比如:身份证号,
此例照常使用的,可试试吧!
[ 本帖最后由 qingfameng 于 2010-3-5 14:41 编辑 ]