急,急,简单ADO问题(100分)

  • 主题发起人 张林林
  • 开始时间

张林林

Unregistered / Unconfirmed
GUEST, unregistred user!
我用ADO打开一VFP5。0数据库,可存不上数据,请帮忙,具体代码如下
with table2do
begin
if Active then
close;
strtemp := libname;
str := ExtractFileName(strtemp);
do
t := pos('.',str);
str := copy(str,1,dot-1);
TableName := str;
str1 := ExtractFilePath(strtemp);
strconnect := 'Provider=MSDASQL.1;Persist Security Info=False;';
strconnect := strconnect + 'Mode=Read|Write;';
strconnect := strconnect + 'Extended Properties="DSN=Visual FoxPro Tables;UID=;';
strconnect := strconnect + 'SourceDB=';
strconnect := strconnect + str1 + ';';
strconnect := strconnect + 'SourceType=DBF;';
strconnect := strconnect + 'Exclusive=No;BackgroundFetch=Yes;';
strconnect := strconnect + 'Collate=Machine;Null=Yes;Deleted=Yes;"';
connectionstring := strconnect;
Open;
APPend;
FieldByName('ABC').AsString :='123';
Post;
DeleteRecords(ARALL);
end;
1。其中执行到 Post 时会出错,我这样打开数据库有错吗?
2。如想将数据库中的所有纪录都删除用DeleteRecords(ARALL)可以吗?
 
1。是不是另一个主键没有赋值?
2。sql语句:
delete from tabelname
 
1.将append 换成 Insert 试试.
2.其实用Ado联接VFP是通过ODBC的, 你不如直接用ODBC联接.
 
查看数据库结构,是否有不允许为空的字段
 
换INSERT也不行,我想是打开方式或状态不对,好像少设置一个属性
 
1. try this or use insert into ;
Open;
edit;//Add this;
APPend;
2. Delete yourTable where ...
 
VF 数据库都允许为空
 
wumeng
edit ,insert 都不行,快救救我
 
是不是ado空间设为只读属性不许写操作?
 
ADO中READONLY := FALSE;
 
你的出错信息是什么?
 
出错信息
project ZHIAHI.exe raised exception class EOleException with
message 'The opertion requested by the application is not allowed
in this context'.Process stopped .Use Step or Run to continue
 
1.刚开始执行post,出错。我将locktype属性改为ltBatchOptimistic后post不出错,但存不进去
2.执行DeleteRecords(ARALL)命令出错信息为
project ZHIAHI.exe raised exception class EOleException with
message 'The opertion requested by the application is not allowed
in this context'.Process stopped .Use Step or Run to continue
 
会不会是你的ADO版本有问题呢?(猜测的说)
 
千中元大哥
快回答问题呀,求你啦!!!
 
单步跟踪一下,看到哪里出问题。vfp没用过,不敢乱说话,只能帮你提前
 
救命,大家救命。我现在的问题是用ado打开一access库时,用append,post就可以存入数据,
但是用DeleteRecords(ARALL);就出上边错误信息。
 
我正在用Ado控制Access,我看你的Code,是Adotable直连到数据库的,
我的感觉你还是用Adoquery等连接的好,向你这样的情况,当需要
Post的时候UpdateBatch(arAll), 如果all delete用CancelUpdate(arAll),
即可.另你为什么不用Adoconnection先连接到db,然后将其他dateset
指向这个Adoconnection,你这样如果table多,太烦了吧?
 
问题解决了,多谢各位
 
顶部