Solved

SQL Server does not exist or access denied?

Posted on 2003-11-06
12
54,241 Views
Last Modified: 2011-08-18
I created a SQL server instance called 'Instance'. In the databases, I created a database called 'DB'. I selected "use the local system account". Authentication mode is "Windows Authentication mode".

Is the following connection string correct?

String connString="server=Instance; database=DB; uid=sa; password=;";   (Should instance be replaced with localhost? Should I replace the uid and password?)

Why am I getting this error message:
"SQL Server does not exist or access denied"?

Thanks.
0
Comment
Question by:samliam
  • 2
  • 2
  • 2
  • +4
12 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 9693250
First of all:
Does sa have permissions on 'DB'?

Second (obvious one): Is SQL Server up and running when you this?

Third:
Try accessing the server by it's IP:
String connString="server=(local); database=DB; uid=sa; password=;";
or
String connString="server=127.0.0.1; database=DB; uid=sa; password=;";
or any other IP.

D'Mzz!
RoverM
0
 

Expert Comment

by:Orbitalgr
ID: 9693271
If when your are browsing your sql server, the name of the instance (under the SQL server group) is Instance don't change it to (Local) or anything. Try this one instead:

connString="server=Instance; initial catalog=DB; uid=sa; pwd=;"

PS
If it doesn't work that way either.
1) R u sure your SQL server is running?
2) The sa passward is blank?

Hope i was helpfull,

Orbital.
0
 
LVL 42

Accepted Solution

by:
frodoman earned 25 total points
ID: 9693687
With the connection string you're sending, you probably want the connection mode set to SQL Server validation instead of Windows (otherwise there's no point in sending the sa user in your string...)

If you keep your authentication Windows based, then you need to make sure that the Windows user has the appropriate access rights for whatever you're trying to do.

I would also consider changing your server name to "(local)\Instance".  Orbital is right that you *probably* don't need to, but if there's another "Instance" on your cluster you potentially have a problem.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Assisted Solution

by:Orbitalgr
Orbitalgr earned 25 total points
ID: 9693882
frodoman is right :) I didn't notice that you use windows authentication mode.
You don't need to provide uid and pwd in such a case. Try connecting to your database with a trusted connection like:
connString= "Data Source=Instance;Initial Catalog=DB;Integrated Security=SSPI;"
If i doesn't work that way, follow frodoman advice by giving as a data source the: "serverName\Instance Name"
I am not sure but I think that this one applies only to Sql Server 2000.

Good Luck
Orbital.
0
 

Author Comment

by:samliam
ID: 9697292
How do I add a user to the db? 'sa' is reserved, but I do not see it in the list. When I try to add a different user, it says "login already exists."
0
 

Author Comment

by:samliam
ID: 9698773
SQL Server Enterprise Manager, if I expand Databases\myDB, click on 'Users', there is only 1 item: "dbo".
If I double-click "dbo", a 'databse user property dialog' shows. In Permit in databse role, only 'public' is checked. If I click "permission", myTable has all select, insert, etc checked (except for EXEC).

If I right-click 'dbo' ->New Databse User, I cannot add 'sa', it is 'reserved.' I cannot add my Windows account, it says 'already exists.'

What do I do?
0
 
LVL 42

Expert Comment

by:frodoman
ID: 9700797
Samliam,

I think what you want is to drill into Security -> Logins instead of Database -> Users.

Try this and you should see the Windows account that you you're trying to add already exists.  Right-Click and then set the access permissions as necessary.

I would still recommend that instead of doing this you change your access validation to SQL Server and connect as you were trying in your original post.  Windows validation can be more difficult to troubleshoot so I'd get an SA connection working first and then move to Windows validation if that's where you want to be.

Hope that helps...
0
 

Expert Comment

by:fricitra
ID: 10665260
I had the same problem.
My SQL server 2000 database running on WIN- NT and server name in 'NTSERVER'.
SQL server name also 'NTSERVER'.

I installed .NET in my machine (Win 2000) and create connection string in ASP.NET to NTSERVER.

I receievd the same error message 'SQL Server does not exist or access denied', when I try to connect with IP address instead of server name on Data source - It's connected.

I need alternat solution other than IP address.

Pl, provide solution ...
0
 

Expert Comment

by:jnybbs
ID: 11169656
you want to use server name instead of ip address, be sure that you've added an alias for the said server on the client utility or host file and they are not in conflict with one another
0
 

Expert Comment

by:giamm
ID: 13383642
I have the same problem!!!

i tested the user credential with enterprise manager and all seems right

but by code also if i use de sa login i receive the same message:
SQL Server does not exist or access denied
this is my connection string:
Connection Timeout=20;Server=192.168.254.50;Database=DBNAME;Persist Security Info=False;Trusted_Connection=true;User ID=sa;Password=XXXX;
0
 

Expert Comment

by:jnybbs
ID: 13417782
try:

Connection Timeout=20;Server='192.168.254.50';Database=DBNAME;Persist Security Info=False;User ID='sa';Password='XXXX';
0
 

Expert Comment

by:giamm
ID: 13422720
i resolved it
yes was "Trusted_Connection=true"
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 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