Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

Database failover question

ok, so I have a database that is intrinsical to my program, the first thing I do when my program runs is open the database, if the database does not open, I try the next database, if that doesnt work, the program terminates.  Here is my code

Public Function Open_Database(ByVal strDatabase As String) As ADODB.Connection

Dim ConnectionString1 As String
Dim ConnectionString2 As String
Dim MyConnection As ADODB.Connection

On Error Resume Next

Set MyConnection = New ADODB.Connection

ConnectionString1 = "Driver={SQL Server};User=???;Password=?/?????;Server=???????;Database=" & strDatabase & ";"
ConnectionString2 = "Driver={SQL Server};User=?????;Password=???????;Server=???????;Database=" & strDatabase & ";"


MyConnection.Open ConnectionString1

If Err.Number <> 0 Then

    MyConnection.Open ConnectionString2
   
    If Err.Number <> 0 Then
        MsgBox "There was an error opening the " & strDatabase & " Database. Program cannot log and will terminate. Please investigate immediately!"
        Shell "C:\Terminate.exe", vbHide
    End If

WHen I run my program, I get the error message I stipulated.  I have checked the user name Spellings (all correct), the pwd spellings (again all correct) and the server connection(works)
0
Wonderflub
Asked:
Wonderflub
  • 3
  • 2
1 Solution
 
WonderflubAuthor Commented:
Ok, so when I run my program from the VB devel environment, and not formteh compiled DLL.... I can connect to the intial to write a flag, but when it tries to log ot the log database, a white box that looks abotu the sixe of the project test form, opens up in teh corner with nothing in it, and the program freezes... ANY suggestions, this is uber strange....
0
 
Michael_DCommented:
What error did you get ?
0
 
WonderflubAuthor Commented:
well, when I ran it from the compiled DLL I get the error that I stipulate in my msgbox.... cannot gconnect, program will terminate.

WHen I run it in VB6 environment, I get no error, it connects to the first database fine, XnetSQL on the server, but when it tries to connect to the log database to log the errors, I get a white box wigh nothing in it, and the program freezes.  I don't even have a graphical interface for the box to appear....

So I just checked the database, and it is logging the errors, they are there from teh VB test enviro runs, but the program never finished, it just had the silly white box....

Ok, so if it can log and connect when in the VB enviro why not from the compiled DLL????
0
 
WonderflubAuthor Commented:
OK then, nevermind... now it works, What did you do man?????
0
 
Michael_DCommented:
Funny!
Anyway thank you for points!

Good luck!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now