Delphi Dynamic Link Multiple data source execution Operation example

Source: Internet
Author: User

1. First configuration file
[SUBEXAMDEP1]
dbserver= (local)
Dbname=herpeisweixin
Username=sa
Pwd=bjbr
MSG=SUBEXAMDEP1 failure
[SUBEXAMDEP2]
dbserver= (local)
Dbname=herpeisfztj
Username=sa
Pwd=bjbr
MSG=SUBEXAMDEP2 failure
2. Project documents added to Inifiles file
Public
Myini:tinifile;
glapppath:string;
Create Event increase
Glapppath: = Extractfilepath (Application.exename);//Gets the path of the current running program
Myini: = tinifile.create (Glapppath + ' Subdbconfig.ini ');

Initialize form increase
With Spsp_syncorg do
Begin

  ProcedureName:=‘P_SYNCORGINF‘;  Parameters.CreateParameter(‘@ID_Org‘, ftInteger, pdInput, 0,null );  Parameters.CreateParameter(‘@ID_OrgReservation‘, ftInteger, pdInput, 0, null);  Parameters.CreateParameter(‘@RetMsg‘,ftString,pdOutput,50,null)end;    实现按钮事件    procedure TFormPeisOrgReservation.btn_IssuedSubClick(Sender: TObject);

Var
I:integer;
dbserver,dbname,username,pwd:string;
cursecetion:string;
Curid_org,curid_orgreservation:integer;
msg,retmsg,summsg:string;
Sucessnum:integer;

Begin
Msg:= ";
Retmsg:= ";
Summsg:= ";

If not aqmain1.active thenbegin exit;end;lst1. Clear; Curid_org:=aqmain1.fieldbyname (' id_org '). Value; Curid_orgreservation:=aqmain1.fieldbyname (' id_orgreservation '). value;sucessnum:=0; Myini.readsections (Lst1. Items); for I:=0 to Lst1. Count-1 Dobegin Cursecetion:=lst1.  Items[i];  Dbserver:=myini.readstring (cursecetion, ' dbserver ', ');  Dbname:=myini.readstring (cursecetion, ' DBNAME ', ');  Username:=myini.readstring (cursecetion, ' USERNAME ', ');  Pwd:=myini.readstring (cursecetion, ' PWD ', ');   Msg:=myini.readstring (cursecetion, ' MSG ', ');      Try Adoconnection1sub.connected:=false; Adoconnection1sub.connectionstring:= ' Provider=SQLOLEDB.1; password= ' +pwd+ '; Persist Security info=true;      User id= ' +username+ '; Initial catalog= ' +dbname+ ';D ata source= ' +dbserver;      Adoconnection1sub.connected:=true; SpSP_SyncOrg.Parameters.ParamByName (' @ID_ORG ').      value:=curid_org; SpSP_SyncOrg.Parameters.ParamByName (' @ID_OrgReservation ').      Value:=curid_orgreservation;      Spsp_syncorg.execproc; Retmsg:=sPSP_SyncOrg.Parameters.ParamByName (' @RetMsg ').      Value;      If retmsg= ' sync succeeds! ' then begin sucessnum:=sucessnum+1;      End         If retmsg= ' sync failed! ' THEN BEGIN if summsg= "then begin summsg:=msg;         End ELSE begin summsg:=summsg+ ', ' +msg;      End   End Except End;end;if Sucessnum=lst1. Count thenbegin showmessage (' Sync succeeded! ');   Endelsebegin if summsg= ' then begin ShowMessage (' execution failed! ');   End ELSE begin ShowMessage (SUMMSG); End;end;

End

The interface puts a adoconnection and listbox control

Delphi Dynamic Link Multiple data source execution Operation example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.