Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to check if MS SQL Server is reachable Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Check if MS SQL Server is reachable 04-Jun-03
Category
Database Others
Language
Delphi 5.x
Views
165
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Nik Ozniev

Can I find programmatically if certain MS SQL Server is reachable on net?

Answer:

Here is function, performing check if MS SQL Server is reachable on net against 
given server name (usually host on that MS SQL Server is installed), user name and 
password 
1   
2   function CheckMSSQLServer(fServerName, fUserName, fPsw: string): Bool;
3   var
4     wDb: TDatabase;
5   begin // Check if MS SQL Server is reachable
6     // Important! BDE Must be installed
7     Result := False;
8     wDb := TDatabase.Create(nil);
9   
10    with wDb do
11    begin
12      DatabaseName := 'wDbDatabaseName'; // arbitrary name, must be unique
13      // in current Session
14      Params.Values['SERVER Name'] := fServerName;
15      Params.Values['USER Name'] := fUserName;
16      Params.Values['PASSWORD'] := fPsw;
17      LoginPrompt := False;
18    end;
19  
20    try
21      wDb.DriverName := 'MSSQL';
22      try
23        wDb.Connected := True;
24        wDb.Connected := False;
25      except
26        ShowMessage('Server is not reachable');
27      end;
28      Result := True;
29    finally
30      wDb.Free;
31    end;
32  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC