Solved

SQL Server does not exist or access denied?

Posted on 2003-11-06
12
54,232 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now