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

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

SQL Server does not exist or access denied?

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
samliam
Asked:
samliam
  • 2
  • 2
  • 2
  • +4
2 Solutions
 
rovermCommented:
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
 
OrbitalgrCommented:
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
 
frodomanCommented:
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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
OrbitalgrCommented:
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
 
samliamAuthor Commented:
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
 
samliamAuthor Commented:
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
 
frodomanCommented:
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
 
fricitraCommented:
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
 
jnybbsCommented:
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
 
giammCommented:
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
 
jnybbsCommented:
try:

Connection Timeout=20;Server='192.168.254.50';Database=DBNAME;Persist Security Info=False;User ID='sa';Password='XXXX';
0
 
giammCommented:
i resolved it
yes was "Trusted_Connection=true"
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

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