When retrieving 1 field in 1 record only, you need to use
ExecuteScalar instead of creating a datareader. And by calling The read method twice, you'll force an error!
But this has nothing to do with a login system, where in the code will the username be saved so the user will still be logged in subsequent requests?
Please read the link I provided, and start learning good practices....
Protected Sub btnLoginPan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLoginPan.Click
con = New SqlConnection("Data Source=DAVE-PC\SQLEXPRESS;Initial Catalog=new;Integrated Security=True ")
con.Open()
cmd = New SqlCommand("SELECT Password FROM Registration2 WHERE UserName = ' " + txtUserName2.Text + " '", con) Dim rd1 As string =Convert.ToString( cmd.ExecuteReader()) If rd1 =Null Then Response.Write("UserName is incorrect")
Else If rd1 = txtPassword2.Text Then
Response.Redirect("MusicArena.aspx")
Else
Response.Write("Incorrect Password")
End If
End Sub
ok u try this(above quatepost) codde..and change ExcuteReader to ExcuteScaler()...
hans_v
All-Star
35986 Points
6550 Posts
Re: Asp.net login page
May 07, 2012 03:04 PM|LINK
When retrieving 1 field in 1 record only, you need to use ExecuteScalar instead of creating a datareader. And by calling The read method twice, you'll force an error!
But this has nothing to do with a login system, where in the code will the username be saved so the user will still be logged in subsequent requests?
Please read the link I provided, and start learning good practices....
sriramabi
Contributor
4351 Points
1277 Posts
Re: Asp.net login page
May 07, 2012 03:07 PM|LINK
ok u try this(above quatepost) codde..and change ExcuteReader to ExcuteScaler()...
thank u