Checking For a valid connection

Results 1 to 2 of 2

Thread: Checking For a valid connection

  1. #1
    Rob Reid Guest

    Default Checking For a valid connection

    I am trying to write a piece of code that checks a connection, where the user enters the DSN name that they wish to check.<BR>The thing is with On Error Resume Next removed the code works when I enter a valid connection string and goes into debug mode if I enter a load of bollox. When I add Debugging though, and check for errors after I try and open the connection, the error count is greater than zero whether it is a valid DSN name or not.<BR>Why is this.<BR>My code is here<BR><BR>On Error Resume Next<BR>DSN = CStr(Request.Form("DSN"))<BR> <BR> if DSN&#060;&#062;"" then<BR> Dim objDBcon <BR> set objDBcon = Server.CreateObject("ADODB.Connection")<BR> <BR> objDBCon.ConnectionTimeout = 30<BR> "DSN=" & DSN & ";"<BR> <BR> if objDBcon.Errors &#060;&#062; 0 then<BR> Response.Write("Errors") <BR> end if<BR> Err.clear<BR> end if

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: Checking For a valid connection

    If there is not error after you open the connection check the connection.state. 1 means it is open therefore valid.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts