我用Delphi7的ADO操作VisualFoxpro7的自由表(指的是单个后缀是DBF的表)
每次只能insert512条记录后出现too many variables的错误,为什么?
我的ADO是MDAC2.6sp2打过补丁的,adoconnection string 是
Provider=VFPOLEDB.1;Data Source=D:\myVFP;Mode=Share Deny None;Password="";Collating Sequence=MACHINE
ADO的类型是OLE DB Provider for Visual Foxpro
附源程序:
unit tube51;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin
ADOConnection1.Open;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
try
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM,:MC)');
for i:=1 to 1000 do
begin
ADOQuery1.Parameters.ParamValues['dm']:='000001';
ADOQuery1.Parameters.ParamValues['mc']:='深发展A';
ADOQuery1.ExecSQL;
end;
finally
ADOQuery1.Close;
ADOConnection1.Close;
end;
end;end.
但将
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM,:MC)');
改为
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM)');
只有一个
ADOQuery1.Parameters.ParamValues['dm']:='000001';
ADOQuery1.ExecSQL;又不会出错
为什么????
是不是Delphi本身的Bug?
每次只能insert512条记录后出现too many variables的错误,为什么?
我的ADO是MDAC2.6sp2打过补丁的,adoconnection string 是
Provider=VFPOLEDB.1;Data Source=D:\myVFP;Mode=Share Deny None;Password="";Collating Sequence=MACHINE
ADO的类型是OLE DB Provider for Visual Foxpro
附源程序:
unit tube51;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin
ADOConnection1.Open;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
try
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM,:MC)');
for i:=1 to 1000 do
begin
ADOQuery1.Parameters.ParamValues['dm']:='000001';
ADOQuery1.Parameters.ParamValues['mc']:='深发展A';
ADOQuery1.ExecSQL;
end;
finally
ADOQuery1.Close;
ADOConnection1.Close;
end;
end;end.
但将
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM,:MC)');
改为
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM)');
只有一个
ADOQuery1.Parameters.ParamValues['dm']:='000001';
ADOQuery1.ExecSQL;又不会出错
为什么????
是不是Delphi本身的Bug?
解决方案 »
- 关于.dat 文件的疑惑
- DLL向主程序中一个自定义对象发送消息
- 横向显示若干数据,用什么控件好?
- 本人新开发了一套进销存软件界面不错,想要与我联系QQ:52505415
- 这里的人真好
- 急!!!!!!!!SQL查询
- 请问能否让TQuery执行出错时不要弹出模式对话框报告出错
- 谁能给个正则分析函数
- 急急急!!!如何在DELPHI中实现将word文档导入和导出到memo中.online waiting......
- 请问如何在调试时查看一个数组如 S1: ARRAY[0..100] OF BYTE的各元素的数值
- 如何把一个字段的值清空????是日期型的!!!
- 现在我的程序 已经卡在这了。哪位仁兄肯帮帮忙(端口通信)!!!!!!!!(help! me)
之前加这句话试试:
ADOQuery1.ParamCheck:=true;
救救我呀
try
for i:=1 to 1000 do
begin
ADOQuery1.sql.clear;
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM,:MC)');
ADOQuery1.Parameters.ParamValues['dm']:='000001';
ADOQuery1.Parameters.ParamValues['mc']:='深发展A';
ADOQuery1.ExecSQL;
end;
finally
ADOQuery1.Close;
ADOConnection1.Close;
end;
我用ADO把汉字写进vfp的dbf中,老是莫名其妙的截掉半个字符
用BDE没问题,操作环境是win2000,delphi7
为什么????
改版后怎么热心的高手不见了,我是业余爱好者,好多问题都搞不懂
乞盼赐教
你试试改成这样:
try
for i:=1 to 1000 do
begin
adoquery1.close;
ADOQuery1.sql.clear;
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES (:DM,:MC)');
ADOQuery1.Parameters.ParamValues['dm']:='000001';
ADOQuery1.Parameters.ParamValues['mc']:='深发展A';
ADOQuery1.ExecSQL;
end;
finally
ADOQuery1.Close;
ADOConnection1.Close;
end;
我也遇到类似问题
想将日期插入到SQL数据库里,其中yeam是日期型的
sql.add('insert ttime(yeam) values(''2002-9-18'')');//ok
如果用参数形式
sql.add('insert ttime(yeam) values(:yeam)');
parameters.parambyname('yeam').value:=strtodatetime('2002-9-18');//error我在大富翁上看到了同样的问题,据说是ADO的问题,可是我把它升级了还是通不过,不知道是什么原因
不用Parameters.ParamValues
adoconnection.exec一般没问题
还是这么写吧
for i:=1 to 1000 do
begin
Adoquery1.close;
Adoquery1.Sql.clear;
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES ('00001','深发展A')');
ADOQuery1.ExecSQL;
end;
Adoquery1.close;
Adoquery1.Sql.clear;
ADOQuery1.SQL.Add('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES ('00001','深发展A')');
ADOQuery1.ExecSQL;
改成:
adoconnection.execute('INSERT INTO TBZQDM (ZQDM,ZQMC) VALUES ('00001','深发展A')');不好吗?
新的ado.net中mssql是用sqlconnection
access或oracle、db2等符合old标准的数据库用oledbconnection
其它用odbcconection
如果用delphi
ado一定要升级否则会有问题
当年苦思不得其解
幸亏一同学
一句“升级”点醒我梦中人不过说实话
升级后是没什么问题了