Trouble Opening SQL Server DB

I have a vb6 app that uses a sql server express database.  Suddenly I am having difficulty opening it.  Here is what I use to open the db:

    sWhichSrvr = lstWhichComp.Text
    
    Call Hourglass
    
    Set conn = New ADODB.Connection
    
    If sWhichSrvr = "Remote" Then
        conn.Open "Provider=SQLNCLI10;Server=216.185.199.1,1433\SQLExpress;Database=VIRA;Uid=xxx;Pwd=xxx;"
    Else
        conn.Open "Provider=SQLNCLI10;Server=" & sWhichSrvr & "\SQLExpress;Database=VIRA;Trusted_Connection=yes;"
    End If

Open in new window


Now I get an error when I try to access the db.  What might cause that to change?  Antivirus?  Malware?  I don't think I have added any of that since last use.

Thanks so much!!
Bob SchneiderCo-OwnerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Vitor MontalvãoConnect With a Mentor MSSQL Senior EngineerCommented:
Then check the sWhichSrvr value.
Anyway post the error.
0
 
David ToddConnect With a Mentor Senior DBACommented:
Hi

Is database on autoclose?

What is exact error message?

Regards
  David
0
 
Vitor MontalvãoConnect With a Mentor MSSQL Senior EngineerCommented:
It would help if you post the error but by the code if have doubts if the line for the remote connection is correct (you shouldn't need the TCP port when you give the instance name).
Try this one:
   If sWhichSrvr = "Remote" Then
        conn.Open "Provider=SQLNCLI10;Server=216.185.199.1\SQLExpress;Database=VIRA;Uid=xxx;Pwd=xxx;"
    Else
        conn.Open "Provider=SQLNCLI10;Server=" & sWhichSrvr & "\SQLExpress;Database=VIRA;Trusted_Connection=yes;"
    End If 

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Bob SchneiderCo-OwnerAuthor Commented:
I will post the error code and look at the remote cinnection but it is the lcal connection i am hing trouble with...and it worked until just recently
0
 
Bob SchneiderCo-OwnerAuthor Commented:
I am not near my desk and I will post it when I get home but the gist of it is that it can't find the database.  Lets not forget that IT HAS WORKED WELL UNTIL RECENTLY (all caps for emphasis, not for anger :) ).  The db is in the same place.  My concern is what would cause it to suddenly stop working.  Hmmmm.....
0
 
Bob SchneiderCo-OwnerAuthor Commented:
Now it is working, and my machine just underwent an upgrade...wierd.  Thank you.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
If it happens again, please send the error. There should be something in the error message that can lead us to the problem.

Cheers
0
All Courses

From novice to tech pro — start learning today.