View Single Post
Old September 28th, 2004, 03:26 AM
hums hums is offline
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

        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


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

        End Try

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

        End If
    End Function