3
Answers

How to create a login form in asp.net

Photo of Micalgray

Micalgray

13y
2.6k
1
Hi,
How to create a login form in asp.net ?

Answers (3)

0
Photo of Satyapriya Nayak
NA 39.3k 13.3m 13y
Hi  Micalgray,
Here is your desired code.Run the attachments.


Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page
    Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
    Dim con As New SqlConnection(strConnString)
    Dim str As String
    Dim com As SqlCommand
    Dim obj As Object

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        con.Open()
        Session("username") = TextBox1.Text
        Session("password") = TextBox2.Text
        str = ("Select count(*) from Login where UserName='" + Session("username") & "' and Password ='") + Session("password") & "' "
        Dim com As New SqlCommand(str, con)
        obj = com.ExecuteScalar()
        If CInt(obj) <> 0 Then

            Response.Redirect("Welcomeuser.aspx")
        Else

            Response.Redirect("invalid.aspx")
        End If
        con.Close()
    End Sub
End Class



Thanks
If this post helps you mark it as answer
Accepted
0
Photo of Satyapriya Nayak
NA 39.3k 13.3m 13y
Hi Micalgray,





If this post helps you mark it as answer



Thanks



0
Photo of Satyapriya Nayak
NA 39.3k 13.3m 13y
Hi Micalgray,

Please go through Our recommended articles section.


Thanks