I'm learning how to check if user exist. I have write below codes:
SqlDataSource is dedicated to GridView1 as data source.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
SqlDataSource1.SelectCommand = "SELECT COUNT(*) AS Result, username, password " & _
" FROM Tabela1 " & _
" GROUP BY username, password " & _
" HAVING (COUNT(*) = 1) " & _
" AND username = '" & TextBox1.Text & "'" & _
" And password = '" & TextBox2.Text & "'"
If GridView1.Rows.Count < 1 Then
Label1.Text = "user not found it"
Label1.Text = "user found it"
But funny thing is when I type wrong username, or password the code is ok, and get statement "user not found it", and also gridview does not show, as no results come out from Sql . But, after I write correct username, and password, gridview show results, but label1 has still text as "user not found it ". Then I click button again, then label has correct text "user found it".
So, basic problem is not in code it self. But that I need to click 2x button to get right result as end user.
I have add it attachment of my project, if someone would like to check it directly.
Thank you in advancee for help.