Denied access to SQL Server through application


My web app runs on my machine fine when querying the local database.
However when I want the app to query a sql server instance on another machine on the network
it does not allow me access. I know my connection string is correct - I can access
the database through Enterprise manager, and definately am using the right username
and password. The error message is something to this effect "Cannot connect to server, invalid
username or instance doesn't exist" - poor description but am not at work to get the exact message.
It fails when doing the whole objConnection.Open() thing.
However it works fine when I am accessing the web app when connection through the Internet.
ie through a machine not connected to the network.
Any ideas ?
Who is Participating?
Joe JenkinsCommented:

The credentials probably are correct.  The DSN may be set up wrong... Let's see what you have..

1. Admin Tool -> ODBC Connections -> System DSN Tab
2. Select EggX DSN, hit configure

Give me a run-down of what you have in there.  Is the database selected?  That error message you posted is telling me that the SQL Server you're connecting to does not exist or that it just can't find the database.  You can try setting up a User DSN as well and when you click finish it will give you a Test Connection button to test it.  If it works from there, your identically configured SYSTEM DSN should work fine.  

Let's fill in those blanks and see what we have there.

Also, let me see your connection code in your ASP file.  That could be the source of the problem too.

Joe Jenkins
Joe JenkinsCommented:
A couple questions:

1) Do you have the ability to set up a DSN?
2) If so, have you tried this method?
3) Can you post your current connect string?

Joe Jenkins
gusdogsAuthor Commented:
Hey bud, unfortunately I can only try that
when I get back to work on Monday - will let you know.
Many thanks
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Joe JenkinsCommented:
Sounds good.  Thanks for checking in during the weekend.  

Talk to next week.

Joe Jenkins
You need to have both Named Pipes and TCP enabled. I guess ASP.NET would connect via TCP but Ent. Manager via Named Pipes.

Check out this:
gusdogsAuthor Commented:
Hey Joe

Tried using a dsn to no avail, here are the error messages I get
and the respective connection strings used in each

Error Message -
SQL Server does not exist or access denied.
Connection string used -
"Server=EGGX; Database=EggX; User ID=sa; Password=3159"

Using a DSN, I get...
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
Connection string used -
"Provider=sqloledb;Data Source=EggX;Initial Catalog=EggX;User Id=sa; Password=3159;"

Once Again I'm 100% sure the credentials are correct.


Both Named Pipes and TCP are enabled.

Any other ideas guys ?

Joe JenkinsCommented:
I take it the DSN was configured incorrectly?  I'm glad to have been of assistance!

Joe Jenkins
gusdogsAuthor Commented:

I didn't realise we could post a reponse and accept the answer -
new to Experts-Exchange ! Once I selected the correct database,
and not Master, it worked - what an idiot ! Thanks man.
Joe JenkinsCommented:
hah!  That's great.  I'm glad you got it.  I bet you'll never make that mistake again!  

Great job!

Joe Jenkins
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.