SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Brampton, Ontario
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Database Connection question

    I was wondering if i can create an if/else statement that checks if my connection string that opens a database ie:
    Code:
    cnnDB.Open Application.Contents.Item("CONNECTION_STRING" )
    (the actuall connection string is in my global.asa file incase u were wondering) ...or if the database can't be found or opened, will run some other code... like a message?

    hope u get what i mean.

    this is just incase a user has the DB opened, or is in the process of overiting the DB or something, the page would not display that Microsoft JET Database Engineerror but display a message i set up in the if/else statement.

    thanks.

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,289
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Something like this will work:
    Code:
    	on error resume next	   ' <== KEY!!!! Won't do it otherwise...
    	set my_Conn = Server.CreateObject("ADODB.Connection")
    	my_Conn.Errors.Clear
    	Err.Clear
     
    	my_Conn.Open strConnString
    	for counter = 0 to my_conn.Errors.Count -1
    		 ConnErrorNumber = Err.Number
    		 ConnErrorDesc = my_Conn.Errors(counter).Description
    		 If ConnErrorNumber <> 0 Then
    			Response.Write "Error Number = " & ConnErrorNumber & _
    								 ", Description  = " & ConnErrorDesc
    		 end if
    	next
    	my_Conn.Errors.Clear
    	Err.Clear
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    Brampton, Ontario
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help

    it worked out great.... I actually wanted it to display a different message, and not an "ERROR" message but i modified it...


Bookmarks

Posting Permissions

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