Hi,
How to create a login form in asp.net ?
How to create a login form in asp.net
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 24, 2011, 7:23 AM EDT
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
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 23, 2011, 10:11 PM EDT
Please go through Our recommended articles section.
Thanks
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 24, 2011, 7:03 PM EDT
If this post helps you mark it as answer
Thanks