ASP
  Home arrow ASP arrow Page 3 - Using ASP & SQL To Ping A Remote Server
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Using ASP & SQL To Ping A Remote Server
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2001-11-28

    Table of Contents:
  • Using ASP & SQL To Ping A Remote Server
  • An overview of the procedure
  • Creating the stored procedure
  • The GetPingStats() ASP function
  • Analyzing the ping attempts
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using ASP & SQL To Ping A Remote Server - Creating the stored procedure


    (Page 3 of 6 )

    As mentioned above, our function will connect to the SQL server and execute the sp_PingServer stored-procedure. To create the procedure, fire up Query Analyser on the SQL Server, login, and enter the following commands into the query window:

    USE MYDATABASE

    GO

    CREATE PROC sp_PingServer

    @strServerIP VARCHAR(50)

    AS

    DECLARE @strCmd VARCHAR(60)

    SELECT @strCmd = 'ping ' + @strServerIP

    EXEC Master..xp_cmdShell @strCmd

    GO


    NB: This example creates the stored procedure in the "MYDATABASE" database. You should change this to match the name of your database.

    If all goes well, Query Analyser will respond with:

    The command(s) completed successfully.

    Our newly created stored procedure, sp_PingServer, simply calls an extended stored procedure, xp_cmdShell, which is part of the master database.

    Extended stored procedures do not reside in the database like other stored procedures. Instead, they are part of a library of DLL’s. Xp_cmdShell is part of the xplog70.dll library, typically located in the \Program Files\Microsoft SQL Server\MSSQL\Binn directory of the SQL Server.

    The xp_cmdShell extended procedure takes one parameter, which is a windows shell command to be executed locally on the server. Any command or program that can be executed in a normal DOS prompt window, such as xcopy, dir, mem, ftp, del, etc can be passed as this parameter.

    When our stored procedure is ran, it executes the command and returns the results. Each line returned by the command is added to the result set as a new row. Here is an example of running the stored procedure:

    The result of executing sp_PingServer localhost

    If you open a new DOS prompt window and execute the ping command against localhost (i.e. “ping localhost”), then you will see that the results are exactly the same.

    Now that we’ve covered the details of creating the stored procedure that will actually execute the ping command for us, let’s create the ASP function, which will do all of the processing work.

    More ASP Articles
    More By Mitchell Harper


     

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway