p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   SQL Server / Login failed for user 'NT AUTHORITY (http://p2p.wrox.com/showthread.php?t=20826)

ElPato November 4th, 2004 11:06 AM

SQL Server / Login failed for user 'NT AUTHORITY
 
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):



<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;DAT ABASE=Northwind;" />
    <add key="NWindDSN"
    value="DSN=NWind;UID=StudentSQL;PWD=XXXXXXXX;DATAB ASE=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>



charul_shukla November 5th, 2004 02:39 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

jolo98 November 14th, 2004 10:03 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


All times are GMT -4. The time now is 12:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.