p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Server 2005 (http://p2p.wrox.com/forumdisplay.php?f=220)
-   -   System.Data.SqlClient.SqlException: Login failed f (http://p2p.wrox.com/showthread.php?t=42694)

belete May 17th, 2006 03:00 PM

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()

%>





SQLScott May 17th, 2006 03:35 PM

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")


belete May 18th, 2006 04:10 AM

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



David_the_DBA May 18th, 2006 08:18 AM

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


All times are GMT -4. The time now is 11:31 AM.

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