procedure TForm1.Button1Click(Sender: TObject);
begin
if ADOConnection1.Connected then
begin
ADOConnection1.Close;
ADOConnection1.ConnectionString :=”;
end;
ADOConnection1.ConnectionString :=‘Provider=SQLOLEDB.1;’ +
‘Persist Security Info=false;’ +
‘User ID=’ + Edit1.Text + ‘;’ + // user Name
‘Password=’ + Edit2.Text + ‘;’ + // Password
‘Initial Catalog=’ + Edit3.Text + ‘;’ + // Database
‘Data Source=’ + Edit4.Text; //Nama komputer / server
Screen.Cursor := crHourGlass;
try
ADOConnection1.Open;
Screen.Cursor := crDefault;
MessageDlg(‘Koneksi berhasil !’, mtInformation, [mbOK],0);
except
on E:Exception do
begin
Screen.Cursor := crDefault;
ADOConnection1.Close;
MessageDlg(‘Koneksi Gagal !’+#13#13+‘Exception:’+#13+E.Message, mtError, [mbOK],0);
end;
end;
end;
|