function WirteNb(aUserId,aOpId:string;
aMoney:Double;
aDiseaseDataSet:TDataSource;aBillItemDataSet:TDataSource):widestring;stdcall;
var
a:TDATASET;
B:TDATASET;
begin
a:=TDATASET.CREATE(NIL);
B:=TDATASET.CREATE(NIL);
while not a.eof do
begin
ShowMessage(a.FieldByName('name').asstring);
a.next;
end
在调用时第一次按按钮正常,第二也正常。第三次按下按按钮就会报错。
错误是:Exception EinvalidPointer in module nb.dll at 000027B4
请各位帮忙看看。谢!!
aMoney:Double;
aDiseaseDataSet:TDataSource;aBillItemDataSet:TDataSource):widestring;stdcall;
var
a:TDATASET;
B:TDATASET;
begin
a:=TDATASET.CREATE(NIL);
B:=TDATASET.CREATE(NIL);
while not a.eof do
begin
ShowMessage(a.FieldByName('name').asstring);
a.next;
end
在调用时第一次按按钮正常,第二也正常。第三次按下按按钮就会报错。
错误是:Exception EinvalidPointer in module nb.dll at 000027B4
请各位帮忙看看。谢!!
1.没调用CoInitialize或CoUninitialize()
2.dll最好不要返回string(这个在CSDN上讨论过多次了)
3.在dll中,最好不用ShowMessage而改用MessageBox
4.程序中有内存溢出
2. 去掉aDiseaseDataSet:TDataSource;aBillItemDataSet:TDataSource参数,在DLL中动态生成.
就是说必须要在调用DLL的程序中传数据集传给DLL。只要能处理什么方法都行。
麻烦你给我讲讲动态生成数据集的方法。谢谢
Q: 麻烦你给我讲讲动态生成数据集的方法A:
var
A: TADOQuery;
B: TADOQuery;
begin
CoInitialize(nil);
A := TAdoQuery.Create(nil);
B := TAdoQuery.Create(nil);
A.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=WANGS;Data Source=.';
B.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=WANGS;Data Source=.';
try
A.SQL.Text := 'Select * From TWangs_UserInfo';
A.Open;
while not A.Eof DO
begin
ShowMessage(A.FieldByName('FUserName').AsString);
A.Next;
end;
finally
A.Free;
B.Free;
CoUninitialize;
end;
end;
function WirteNb(aUserId,aOpId:string;
aMoney:Double;
aDiseaseDataSet:TDataset;aBillItemDataSet:TDataSet):WideString;stdcall;var
a,b:TDataSet;
begin
在这个地方就要出问题
a:=TDataSet.create(nil);
b:=Tdataset.cerate(nil);
while not a.eof do
begin
showmessage(a.fieldByName("name").asstring);在这只要一取值就会出现上面那个问题。如果不取值的话就正确
a.next; end;
end;我要把aDiseaseDataSet,aBillItemDataSet这两个数据集里面的内容取出来和另外一个数据库作比较。然后向另一个数据库里写内容。