Monday, June 7, 2004

"SQL Server does not exist or access denied" in Yukon

Bob Beauchemin helped me out with a little problem I was having yesterday, and I figured I'd do my part to disseminate the information.


I was playing around with some software that needs a database back-end. All I have on my machine right now is some interim build of Yukon that we're using at MSDN. I knew I was risking problems by using it, but I didn't really want to have to install SQL Server 2000 as well.


The problem I ran into was when using a connection string like this:



server=.\saratoga;database=MSDNPreview;uid=blah;pwd=foobar


I was getting the following error message



SQL Server does not exist or access denied.


After playing around with it for a while, I discovered that if I ran the program I was testing from a window where it bound to Whidbey, the error message went away. In other words, the problem only existed when using System.Data.SqlClient from the CLR 1.1. I thought I was running into a bug in Yukon that meant I was going to have to install SQL Server 2000. Sigh.


Fortunately, before I went down that road, I asked some of my DM buddies if they knew of this particular issue. Bob came back and said that he'd seen this error before, and that for him, switching the connection string to something like this:



server=localhost\saratoga;database=MSDNPreview;uid=blah;pwd=foobar


fixed the problem (note the use of 'localhost' instead of '.').


And sure enough - it fixed it for me, too. Thanks Bob!

29 comments:

  1. Doesn't that force the SQL libs to use tcp/ip rather than a named pipe? Maybe the error had something to do with permissions?

    J

    ReplyDelete
  2. It may well be that it forces it to TCP/IP, but I don't think that was it. I tried using "net=dbmsscp" (or whatever the syntax is - I looked it up) to force a TCP/IP connection, and still got the same error. So while specifying localhost may *also* have changed it to use TCP/IP, *nothing* was working with '.', so I didn't have much choice.

    ReplyDelete
  3. Just FYI, it looks like it's a MS bug (but their suggestion is that you try changing the connection library as well:

    http://support.microsoft.com/default.aspx?kbid=315159

    ReplyDelete
  4. I was able to replicate this problem even when not running under ASP.NET. Further, as I said, changing the protocol library didn't suppress the bug. So I think it's something other than what's outlined in this KB article, but it's still a good resource for people having that same error message, so thanks for posting it.

    ReplyDelete
  5. Man you ROCK!!! this works, and it's easy! for me it only wanted the server name though. server=servername

    ReplyDelete
  6. Glad I could help, but Bob is the real person to thank.

    ReplyDelete
  7. Um, the blog entry *does* explain the problem and how to solve it.

    ReplyDelete
  8. "SQL Server does not exist or access denied" Give in conncet to ASP.NET to sql but sql will work good with ASP

    ReplyDelete
  9. SQL Server does not exist or access denied" Give in conncet to ASP.NET to sql but sql will work good with ASP

    ReplyDelete
  10. ContactYour DBA or your .Net Faculties for this problem.

    ReplyDelete
  11. Hello Amit Remove your SQL-Server and contact your system administrator to reinstall it.

    ReplyDelete
  12. Thanks for the info below, very helpful. HOWEVER, I do try to remove the 'localhost' thing and put only the sql server name (either local or remote) and it works just fine as long as you are in the network.



    I.e., in your case:

    server=saratoga;database=MSDNPreview;uid=blah;pwd=foobar



    (NOTE: notice I don't even put '.\' or 'localhost\')

    ReplyDelete
  13. Check the password in the Services for MSSQLServer. It maybe keeping the old password after you changed in the network password.

    ReplyDelete
  14. I get the message "SQL Server does not exist or access denied" when using the openquery function to connect to a database in SQL Server 2000. What can I do to fix this?





    Thanks,

    Ben

    ReplyDelete
  15. This message is coming when login to sqlserver. what to do???

    ReplyDelete
  16. I am having the Same Problem , Any one has a solid solution ?

    ReplyDelete
  17. i am having the same problem,any one has correct solution?

    ReplyDelete
  18. When i try to connect sql server then i give messege access denied

    ReplyDelete
  19. I have sqlserver 2000 pro.and .net 2003 with OS XP-service pack-2 but when I am trying to establish the connection with sqlserver from localhost through asp.net web application. I got message sqlserver does not exist whenever my code is right becouse same code running on other system.

    ReplyDelete
  20. Simplest Solution is Remove Your Lan Cable and Plug-In Again

    ReplyDelete
  21. Use this security patch from MS - <BR>http://www.microsoft.com/downloads/details.aspx?familyid=9552d43b-04eb-4af9-9e24-6cde4d933600&displaylang=en

    ReplyDelete
  22. if i run my web page i'm getting the problem like this:

    "SQL Server does not exist or access denied"



    already i've given connection string like this:

    "server=jmj\\begsql;uid=sa;pwd=something;database=victoria_wfms"



    then,why is this problem i'm getting.

    plz guide me.



    thanks,

    victoria.

    ReplyDelete
  23. Hi,



    I've having the same trouble, the issue was, my Avast Server Edition has been expired, so it just block some protocols, in some few computers didn't connect using TCP/IP and also some others didn't connect using the PIPE Server name. Only by removing the Avast Antivirus from the server was the solution.



    Hope it can help you some one.



    Regards

    ReplyDelete
  24. I have tested all your suggestions , but still the error is coming , Iam using dotnet 2002, sql server 7 in OS windows XP Professional.

    what to do? The problem is that it is connecting with remote db server but not with the loacal db server

    Here is the Code.

    con = New SqlConnection("server=server;user id=sa;password=pwd;initial catalog=master")

    ReplyDelete
  25. i have also same problem.i'm useing sql server 2005 please help me.

    ReplyDelete
  26. Iwas facing similar kind of problem. I got multile sites on same IIS server and SQL 2000 server. only for one saite it was giving this error. Rest were working fine. Then I rerstarted only the affected website and it started working smothely

    ReplyDelete
  27. I had the same problem that troubled me almost two days. None of the things on the internet worked, until I got round it completely by accident.



    Cause of the problem was



    data source = local



    Solution



    data source =(local) or .



    Hope this will help some, if not all

    ReplyDelete
  28. i cant fix my problem. I tried all those steps but even its telling Sql server doesnot exist or access denied

    ReplyDelete
  29. I have .net 2003 and sql 2005 in my machine and trying to connect sql 2005 in [remote machine].



    while trying to connect using query analyzer it is connecting. but when i try to connect using connection string it is getting error

    "SQL Server does not exist or access denied"

    ReplyDelete