Tquery的一个问题
像要实现一个从memo1读入数据至数据库中的sql
可是运行连连出错
Project card_pro.exe raised exception class EnoResultset with message 'Error creating cursor handle'. Process stopped. Use Step or Run to continuse.
Project card_pro.exe raised exception class EDBEngineError with message 'Key violation'. Process stopped.Use Step or Run to continuse.
var
i:integer;
len:integer;
position:integer;
str1:string;
str2:string;
begin
for i:=0 to memo1.Lines.Count-1 do
begin
str1:=memo1.Lines.Strings[i];
len:=length(str1)-1;
position:=pos('[',str1)-1;
str2:=copy(str1,position,len-position);
str1:=copy(str1,0,position);
with query1 do
begin
Close;
sql.Clear;
sql.Add('INSERT INTO "Vcard.db" (Vspelling,Vexplain)');
sql.Add('VALUES (:spelling,:explain)');
ParamByName('spelling').AsString:=str1;
ParamByName('explain').AsMemo:=str2;
end;
try
query1.Open;
except
query1.ExecSQL;
end; //edntry
end; //endfor
end;