Tsqlconnection Dynamic Connection

Source: Internet
Author: User

1. Connecting to the SQL Server database

Procedure Tform1.button1click (Sender:tobject);
Var
P:tsqlconnection;
Begin
Try
P: = tsqlconnection.create (nil);
Try
P.connectionname: = ' mssqlconnection ';
P.drivername: = ' MSSQL ';
P.getdriverfunc: = ' getsqldrivermssql ';
P.keepconnection: = true;
P.loginprompt: = False;
P.libraryname: = ' dbxmss.dll ';
P.vendorlib: = ' sqlncli10.dll ';
p.params.values[' Database ': = ' newvisiontest ';
p.params.values[' HostName ': = ' 192.168.1.250 ';
p.params.values[' user_name ': = ' sa ';
p.params.values[' Password ': = ' sa ';
P.params.add (' Getdriverfunc=getsqldrivermssql ');
P.params.add (' Libraryname=dbxmss.dll ');
P.params.add (' Vendorlib=sqlncli10.dll ');
P.params.add (' Vendorlibwin64=sqlncli10.dll ');
P.params.add (' maxblobsize=-1 ');
P.params.add (' Osauthentication=false ');
P.params.add (' preparesql=true ');
P.params.add (' schemaoverride=sa.dbo ');
P.params.add (' Drivername=mssql ');
P.params.add (' blobsize=-1 ');
P.params.add (' isolationlevel=readcommitted ');
P.params.add (' OS authentication=false ');
P.params.add (' Prepare sql=false ');
P.params.add (' connecttimeout=60 ');
P.params.add (' Mars_connection=false ');
P.connected:=true;
Except
On E:exception do
Raise Exception.create (' Database connection not on ');
End
Except
On E:exception do
Begin
Exit;
End
End
End

2. Connecting a middle-tier server

function Tconnthread.connremotesvr (cn:tsqlconnection; const hostname, UserName,
password:string; Const Port:integer): Boolean;
Begin
Try
cn. Close;
cn. DriverName: = ' datasnap ';
cn. Loginprompt: =false;
Cn.connectionname: = ' datasnapconnection ';
cn. Params.clear;
cn. Params.add (' Drivername=datasnap ');
CN.PARAMS.ADD (' hostname= ' +hostname);
CN.PARAMS.ADD (' port= ' +inttostr (Port));
CN.PARAMS.ADD (' user_name= ' +username);
CN.PARAMS.ADD (' password= ' +password);
cn. Open;
Result: =true;
Except
Result: =false;
End
End

Tsqlconnection Dynamic Connection

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.