Unit unit1;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, stdctrls, DB, ADODB, extctrls;
Type
Tform1 = Class (tform)
Adoconnection1: tadoconnection;
Button1: tbutton;
Edit1: tedit;
Groupbox1: tgroupbox;
Label1: tlabel;
Label2: tlabel;
Label3: tlabel;
Label4: tlabel;
User: tedit;
Pass: tedit;
Database: tedit;
Port: tedit;
Rlogin: tbutton;
Button2: tbutton;
Label5: tlabel;
IP: tedit;
Top: tpanel;
Procedure dbconn ();
Procedure mshow (STR: string );
Procedure button1click (Sender: tobject );
Procedure button2click (Sender: tobject );
Procedure rloginclick (Sender: tobject );
Private
{Private Declarations}
Public
{Public declarations}
End;
VaR
Form1: tform1;
Implementation
{$ R *. DFM}
Procedure tform1.dbconn;
Begin
Try
Adoconnection1.connected: = false;
Adoconnection1.close;
Adoconnection1.connectionstring: = 'provider = sqloledb.1; persist Security info = false; user id = '+ User. text + '; initial catalog =' + database. text + '; Data Source =' + IP. text + ',' + port. text + '; Password =' + pass. text;
Adoconnection1.connected: = true;
Rlogin. Enabled: = true;
Except
Rlogin. Enabled: = false;
Mshow ('database connection Error !! ');
End;
End;
Procedure tform1.mshow (STR: string );
Begin
Showmessage (STR );
End;
Procedure tform1.button1click (Sender: tobject );
Begin
Mshow (edit1.text );
End;
Procedure tform1.button2click (Sender: tobject );
Begin
Dbconn ();
End;
Procedure tform1.rloginclick (Sender: tobject );
Begin
Try
Adoconnection1.connected: = false;
Adoconnection1.close;
Rlogin. Enabled: = false;
Except
Showmessage ('An error occurred while disconnecting the database !! ');
End;
End;
End.