C
chinazxy2008
Unregistered / Unconfirmed
GUEST, unregistred user!
大家新年好,开张问题:<br><br>我在服务端定义了一个方法,动态创建Provider供客户端调用:<br>function TTest.sFunIniProvider(Name: string): Boolean;<br> var testPro : TDataSetProvider;<br> testQr : TQuery;<br>begin<br> if FindComponent('dsp'+Name) = nil then<br> begin<br> if FindComponent('qr'+Name) = nil then<br> begin<br> try<br> testQr := TQuery.Create(Self);<br> except<br> result := false;<br> Exit;<br> End;<br> testQr.Name := 'qr'+Name;<br> testQr.DatabaseName := 'hnjtBase';<br> testQr.SQL.Text := Uppercase('select * from zxy_TestM');<br> end;<br> try<br> testPro := TDataSetProvider.Create(Self);<br> except<br> result := false;<br> Exit;<br> End;<br> testPro.Name := 'dsp'+Name;<br> testPro.DataSet := testQr;<br> testPro.Exported := True;<br> end;<br> Result := True;<br>end;<br><br>客户端调用:<br><br>procedure TForm1.btn2Click(Sender: TObject);<br>begin<br> if funIniProvider('testM') Then<br> begin<br> if cdsM.Active Then<br> cdsM.Close;<br> cdsM.ProviderName := 'dsp'+'testM';<br> try<br> cdsM.Active := True;<br> except<br> Raise Exception.Create('连接服务器失败,请重新登录3!');<br> End;<br> end<br> Else<br> Raise Exception.Create('连接服务器失败,请重新登录2!');<br>end;<br><br>但报错:Provider not exported<br><br>请各位帮帮忙