Pls help me code for linq

omel

New member
Joined
Aug 15, 2008
Messages
1
Programming Experience
Beginner
Pls help me,
I want to change my db connection use linq. I dont know to start the connection. I already drag my table and drag my linq datasource on my form. Pls check for me.TQ...here this code

Code:
Private Function YourValidationFunction(ByVal UserName As String, ByVal Password As String) As Boolean



    Dim boolReturnValue As Boolean = False
    Dim strConnection As String = "server=.;database=Assignment;uid=sa;"
    Dim sqlConnection As New SqlConnection(strConnection)
    Dim SQLQuery As String = "SELECT UserName, Password FROM Login"
    Dim command As New SqlCommand(SQLQuery, sqlConnection)
    Dim Dr As SqlDataReader
    sqlConnection.Open()
    Dr = command.ExecuteReader()


    While Dr.Read()
        If (UserName = Dr("UserName").ToString()) And (Password = Dr("Password").ToString()) Then
            boolReturnValue = True
        End If
        Dr.Close()
        Return boolReturnValue
    End While
    Return boolReturnValue
End Function
 
Last edited by a moderator:
Top Bottom