function codetogid(app:tapplication;objects:shortstring;code:shortstring):integer;stdcall;
var adoquery1:tadoquery;
begin
CoInitialize(nil);
application:=app;
dllform:=Tdllform.create(app);
adoquery1.Create(nil);
adoquery1.ConnectionString:='Provider=SQLOLEDB.1;Password=l78z;Persist Security Info=True;User ID=sa;Initial Catalog=cjpos;Data Source=cj/cj';
try
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select gid from '+objects+' where code='''+code+'''';
ADOQuery1.Open;
if ADOQuery1.RecordCount>0 then
result:=ADOQuery1.fieldbyname('gid').AsInteger
else
result:=0;
finally
freeandnil(dllform);
end;
ADOQuery1.Free;
couninitialize;
end;
这样写还是有错,为什么呢?