Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
| Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 17th, 2006, 03:00 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default System.Data.SqlClient.SqlException: Login failed f

Hi all,

Can someone explain it to me why I am getting the following error when I try to connect SQL server express with .NET 2.0?



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.SqlClient.SqlException: Login failed for user ''. The user is not associated with a trusted SQL Server connection.

Here is my code and i am using windows authentication:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<%



    Dim connAkaki As SqlConnection
    Dim cmdSelectAuthers As SqlCommand
    Dim dtrAuthers As SqlDataReader

    connAkaki = New SqlConnection("Server=.\SQLEXPRESS;database=akaki" )


    connAkaki.Open()

    cmdSelectAuthers = New SqlCommand("select Firstname from UserTableTest", connAkaki)
    dtrAuthers= cmdSelectAuthers.ExecuteReader()


    While dtrAuthers.Read()
          Response.Write("<li>")
          Response.Write(dtrAuthers("Firstname"))

    End While

    dtrAuthers.Close()
    connAkaki.Close()

%>




  #2 (permalink)  
Old May 17th, 2006, 03:35 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Wellington, FL , USA.
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You are not passing a username and password. Even SQLExpress needs a username and password to connect. Your connection line should looks somehting like this:

connAkaki = New SqlConnection("Server=.\SQLEXPRESS;database=akaki; UID=username;PWD=password")

  #3 (permalink)  
Old May 18th, 2006, 04:10 AM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hI SQLScott;
Thank you for your reply. But I am using Windows Authentication to connect to the SQL server. Accessing my web application through ISS.
Both Machine-Name\ASPNET, and Network sevices have permission to connect to the database .

I am new to SQL server. I just migrated from access to SQL server


  #4 (permalink)  
Old May 18th, 2006, 08:18 AM
Friend of Wrox
 
Join Date: Dec 2005
Location: , AZ, .
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
Default

You want to look into Permitting your Web Server to impersonate your users.
http://support.microsoft.com/?id=319723
Use Kerberos

David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing System.Data.SQLClient dll mike_abc VB.NET 2 June 3rd, 2011 10:18 PM
System.Data.SqlClient.SqlDataReader - URGENT wk ASP.NET 2.0 Basics 8 September 27th, 2006 05:00 AM
'SYSTEM.DATA.SQLCLIENT.SQLEXCEPTION' soorsha General .NET 0 September 23rd, 2006 11:59 PM
System.Data.SqlClient.SqlException kbarsi Beginning VB 6 2 August 13th, 2005 09:39 PM
Data.SqlClient.SqlException: Login failed csun ASP.NET 1.0 and 1.1 Basics 3 October 15th, 2004 03:01 PM





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