Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server 2008 Not Connecting

Status
Not open for further replies.

PCHomepage

Programmer
Feb 24, 2009
609
US
Running Windows Server 2008 and SQL Server Enterprise, SQL Server is running through the SQL Server Management Studio and I can run queries but I cannot access it via IIS on the same box. I cannot seem to reach it from the command line either. For example, osql -L gives results but sqlcmd -L comes up empty. Oddly, sqlcmd -E -S Server\SQLServer does connect. Any ideas?
 
Have you checked to see if the SQL Browser service is started?

Click Start->Run
Type services.msc
Scroll down to "SQL Browser"



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Yes, it is started but the SQL Server Agent is not. However, I am now all of a sudden getting a response from sqlcmd -L but oddly osql -L does not show (local) as I expected.
 
I'm still having a difficult time connecting to the database through PHP. The drivers are loaded and running, the SQL Server 2008 port is open but it still will not connect. I am trying to use the Windows Authenticated Users which, presumably, is the one logged in. These are the errors, dumped from the PHP sqlsrv_errors function :

Code:
Array
(
    [0] => Array
        (
            [0] => 28000
            [SQLSTATE] => 28000
            [1] => 18456
            [code] => 18456
            [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'.
            [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'.
        )

    [1] => Array
        (
            [0] => 42000
            [SQLSTATE] => 42000
            [1] => 4060
            [code] => 4060
            [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "DATABASE" requested by the login. The login failed.
            [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "DATABASE" requested by the login. The login failed.
        )

    [2] => Array
        (
            [0] => 28000
            [SQLSTATE] => 28000
            [1] => 18456
            [code] => 18456
            [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'.
            [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'NT AUTHORITY\IUSR'.
        )

    [3] => Array
        (
            [0] => 42000
            [SQLSTATE] => 42000
            [1] => 4060
            [code] => 4060
            [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "DATABASE" requested by the login. The login failed.
            [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "DATABASE" requested by the login. The login failed.
        )

)

I haven't used SQL Server (nor Windows) for years so these errors mean little to me. Any ideas?
 
I am not at all familiar with php, but based on the error messages, it appears as though you are trying to connect to a database named "Database" using windows authentication with a user named 'NT Authority\IUSR'.

What you should do is... open SQL server management studio.
In the Object Explorer window, expand "Security". Expand "Logins".
Right click on "Logins" and click "New Login". For the login name, type: NT AUTHORITY\IUSR
Make sure "Windows Authentication" is selected.

Try your php page again. Please let me know if it works. If it doesn't, and the error messages are different, then post the new messages here.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I have been trying to do just that but SQL Server Management Studio gives me an error that I do not have the authority! I am a full administrator and the only user so I've been looking into this issue first.
 
Something thing I look for when I have to deal with login issues where a database name is returned is go to Security>Logins. Find the login that you are really using to access the database. Now check two things...first what is the default database? Does it exist? Then go to User Mapping. If the database does exist, does the login have access to it (is the database checked)? If the database does not exist, set the default to one that the login does have access to.

Next check that a database by the name Database really exists (or if you put a 'cover' name there, check that the real one exists) and that the login has permission to access it.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top