Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
| Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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 September 28th, 2004, 03:26 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Urgent : Getting Error :Login failed for user sa

When i start my application i'm getting this error ::
Login failed for user sa. Reason Not associated with a trusted SQL Server connection.

 Public Function exists(ByVal username As String, ByVal pwd As String)

        Dim con1 As New SqlConnection(" server=(local);uid=sa;pwd=;database=usersdb;")
        Dim myreader1 As SqlDataReader
        Dim eid
        Dim cnt, count As Integer
        Dim ex As Boolean

        Try
        con1.Open()
        Dim sqlcommand1 As SqlCommand
        sqlcommand1 = New SqlCommand("select eid,cnt as count(*) from userdetails where usrname = '" & username & "' and pwd=' " & pwd & "' ", con1)
        myreader1 = sqlcommand1.ExecuteReader()
        Do While (myreader1.Read())
            eid = myreader1("eid").ToString()
            ex = True
        Loop

        Finally

        If Not (myreader1 Is Nothing) Then
            ex = False
            myreader1.Close()
            con1.Close()
        End If

        End Try

                If ex Then
            Label2.Text = "user Exists"
        Else
            Label2.Text = "User does not exists"

        End If
    End Function

  #2 (permalink)  
Old September 28th, 2004, 05:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

It sounds like your SQL Server is only setup to allow Windows logins (Trusted Connection = Windows Login).

Look up "Mixed Mode security" in BOL and you'll see how to change it to accept SQL Server logins too.

If you're going to set-up Mixed Mode security then you should create a new SQL Server account to use with your ASP pages that has just the privileges your application needs. Its just a massive security risk to run your application as the 'sa' account - even more so if there's no password on that account (look up "passwords, adding" in BOL).

hth
Phil


Similar Threads
Thread Thread Starter Forum Replies Last Post
Login failed for user 'sa' scarlisle BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 29th, 2009 09:51 AM
Login Failed for User sa r_taduri Crystal Reports 1 November 29th, 2009 09:50 AM
Login failed for user 'sa'. ernestlambert BOOK: ASP.NET Website Programming Problem-Design-Solution 2 March 7th, 2005 12:26 PM
Error: Login failed for user sa -urgent hums ADO.NET 5 September 28th, 2004 05:52 AM
Login failed for user 'sa' ameg BOOK: Beginning ASP 3.0 5 April 6th, 2004 01:52 AM





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