关于网友提出的“ DLL高手请进,vb多次调用该dll后会出现访问冲突”问题疑问,本网通过在网上对“ DLL高手请进,vb多次调用该dll后会出现访问冲突”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: DLL高手请进,vb多次调用该dll后会出现访问冲突描述:
function GetDeliverNotify(DNNO :PChar):PChar;stdcall
var
dono:shortString;
DoDate:shortString;
prodcode,prodname, DriverLicense,
dnStatus:shortString;
dnAbol,doAbol,doStatus:shortString;
adoqry:TAdoQuery;
sResult:shortString;
begin
adoqry:= TAdoQuery.Create(nil);
sResult:='True';
try
adoqry.ConnectionString:='Provider=SQLOLEDB.1;Password=*****;'
+'Persist Security Info=True;User ID=***;'
+'Initial Catalog=*****;Data Source=******'; //www.tccyd.com
adoqry.close;
adoqry.SQL.Clear;
adoqry.SQL.Add('SELECT * from deliverorder where dnno='''+DNNO+'''');
adoqry.Open;
if adoqry.Eof then
sResult:='无相应的装运通知单!'
else
begin
dnStatus:=adoqry.FieldByName('dnStatus').AsString;
dnAbol:=adoqry.FieldByName('dnAbol').AsString;
doAbol:=adoqry.FieldByName('doAbol').AsString;
doStatus:=adoqry.FieldByName('doStatus').AsString;
dono:=trim(adoqry.fieldbyname('DONO').AsString);
DoDate:=trim(adoqry.fieldbyname('dodate').AsString);
prodcode:=adoqry.fieldbyname('prodCode').AsString;
prodname:=trim(adoqry.fieldbyname('prodName').AsString);
DriverLicense:=trim(adoqry.fieldbyname('driverLicense').AsString);
if(dnAbol='Y')then
raise Exception.Create('该装运通知单已作废! ');
sResult:='True'+ chr(13) + chr(10)
+ prodname + chr(13) + chr(10)
+ DoDate + chr(13) + chr(10)
+ prodcode + chr(13) + chr(10)
+ DriverLicense + chr(13) + chr(10)
+ dono+ chr(13) + chr(10);
end;
adoqry.close;
except on e:Exception do
begin
sResult := e.Message;
end;
end;
getmem(result,length(sResult)+1);
StrPCopy(result,sResult);
end;