各位好,我在判断数据库有相同的字段,采用下面的方法,但不对,请问能有更好的
方法吗?谢谢!function TadduserF.checkpactno(telphone:string):boolean;
begin try
ADOQuery1.Close;
ADOQuery1.SQL.Add('select telphone from telphone where telphone=:telphone ');
ADOQuery1.FieldByName('telphone').AsString;
ADOQuery1.Open; if not ADOQuery1.Eof then
result :=false
else
result :=true;
ADOQuery1.Close;
ADOQuery1.Free; except
result:=false;
end;
ADOQuery1.SQL.Add('select * from telphone where telphone=telphone ');
var
telphone :string;
ADOQuery1.SQL.Add('select Count(*) as Count from telphone where telphone=:telphone ');
ADOQuery.Open;
if ADOQuery1.FieldsByName('Count').asinteger > 0 then
Result := True
else
Result:= false;
ADOQuery1.Close;
ADOQuery1.Free;
begin
ADOConnection1.GetFieldNames(表名,StringList);
if StringList.IndexOf(字段名)>0 then
showmessage('有字段名')
else
showmessage('无字段名');
function TadduserF.checkpactno(telphone:string):boolean;
begin try
ADOQuery1.Close;
adoquery1.sql.clear;
ADOQuery1.SQL.Add('select telphone from telphone where telphone=:a ');
ADOQuery1.Parameters.ParamByName('a').value:=telphone;
// 或 ADOQuery1.Parameters.ParamByName('a').asstring:=telphone; ADOQuery1.Open; if not ADOQuery1.Eof then
result :=false
else
result :=true;
ADOQuery1.Close;
ADOQuery1.Free; except
result:=false;
end;