Subject: SQL Server / Login failed for user 'NT AUTHORITY
Posted By: ElPato Post Date: 11/4/2004 10:06:58 AM
In trying to set up the SQL/Server examples from the Wrox Beginning ASP book I am getting the error below. Originally I recieved errors with the connection strings, but then got that, I think, corrected, or at least changed errors, and now am faced with this one.

Any ideas?

Thanks

---------------------------------------------------------------------

The error occurs on the open method of the connection object, and displays as:

Server Error in '/students' Application.
----------------------------------------------------------------------

ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\LOCAL SERVICE'. ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\LOCAL SERVICE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\LOCAL SERVICE'. ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NT AUTHORITY\LOCAL SERVICE'.



My DSN as setup in the web.config file (password is masked out):

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    <compilation debug="true"/>
        <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
  <appSettings>
    <add key="NWind"
         value="Initial Catalog=NWind;UID=StudentSQL;Password=XXXXXXXX;DATABASE=Northwind;" />
    <add key="NWindDSN"
    value="DSN=NWind;UID=StudentSQL;PWD=XXXXXXXX;DATABASE=Northwind;" />
  </appSettings>
</configuration>
*******

The code (pretty much directly from the Wrox Beginning ASP Databases) is copied below:

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.Odbc" %>

<html>
  <head></head>
  <body>
    <h4>First Example: Listing data from the Employees table</h4>
    <asp:DataGrid id="dgNameList"
     ... ... ...
     />
  <body>
</html>

<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
    Dim oODBCConnection As OdbcConnection
    Dim sConnString As String = ConfigurationSettings.AppSettings("NWindDSN")
    oODBCConnection = New OdbcConnection(sConnString)
    oODBCConnection.Open()
    Dim strSQL As String = "SELECT FirstName, LastName, Country " & _
                           "FROM Employees;"
    Dim objCommand As New ODBCCommand(strSQL, oODBCConnection)

   Response.Write("ServerVersion: " & _
             oODBCConnection.ServerVersion & _
             vbCRLF & "Datasource: " & oODBCConnection.DataSource & _
             vbCRLF & "Database: " & oODBCConnection.Database)

   dgNameList.DataSource = objCommand.ExecuteReader()
   dgNameList.DataBind()
   oODBCConnection.Close()
End Sub
</script>


Reply By: charul_shukla Reply Date: 11/5/2004 1:39:09 AM
Check your SQL Server authentication properties, it might be in windows authentication only mode. If so try to change that in Mixed mode and run the code again.

Charul Shukla
Reply By: jolo98 Reply Date: 11/14/2004 9:03:14 AM
>>The code (pretty much directly from the Wrox Beginning ASP Databases) is copied below:

<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.Odbc" %>

<html>
  <head></head>
  <body>
    <h4>First Example: Listing data from the Employees table</h4>
    <asp:DataGrid id="dgNameList"
     ... ... ...
     />
  <body>
</html>

<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
    Dim oODBCConnection As OdbcConnection
    Dim sConnString As String = ConfigurationSettings.AppSettings("NWindDSN")
    oODBCConnection = New OdbcConnection(sConnString)
    oODBCConnection.Open()
    Dim strSQL As String = "SELECT FirstName, LastName, Country " & _
                           "FROM Employees;"
    Dim objCommand As New ODBCCommand(strSQL, oODBCConnection)

   Response.Write("ServerVersion: " & _
             oODBCConnection.ServerVersion & _
             vbCRLF & "Datasource: " & oODBCConnection.DataSource & _
             vbCRLF & "Database: " & oODBCConnection.Database)

   dgNameList.DataSource = objCommand.ExecuteReader()
   dgNameList.DataBind()
   oODBCConnection.Close()
End Sub
</script>>>>

This code above is working fine, I'm using this as a pattern when I started out. That login failure was in your SQL Server authentication. It could be the user has no permission to access/logon to the northwind database. Try to check properties of your sql server if your using the right authentication method.




jrd

Go to topic 22093

Return to index page 717
Return to index page 716
Return to index page 715
Return to index page 714
Return to index page 713
Return to index page 712
Return to index page 711
Return to index page 710
Return to index page 709
Return to index page 708