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

x
?
Solved

Trouble Opening SQL Server DB

Posted on 2013-05-14
7
Medium Priority
?
399 Views
Last Modified: 2013-05-16
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!!
0
Comment
Question by:Bob Schneider
  • 3
  • 3
7 Comments
 
LVL 35

Assisted Solution

by:David Todd
David Todd earned 668 total points
ID: 39167609
Hi

Is database on autoclose?

What is exact error message?

Regards
  David
0
 
LVL 52

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 1332 total points
ID: 39167612
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
 

Author Comment

by:Bob Schneider
ID: 39167646
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 52

Accepted Solution

by:
Vitor Montalvão earned 1332 total points
ID: 39168073
Then check the sWhichSrvr value.
Anyway post the error.
0
 

Author Comment

by:Bob Schneider
ID: 39168854
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
 

Author Closing Comment

by:Bob Schneider
ID: 39170137
Now it is working, and my machine just underwent an upgrade...wierd.  Thank you.
0
 
LVL 52

Expert Comment

by:Vitor Montalvão
ID: 39170801
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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question