.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Use Of Login Control in Asp.net with VB.net

Posted By:Gowthammanju       Posted Date: August 29, 2011    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

This article explains about usage of login control in asp.net with vb.net
 

Hi,

Just drag and drop the login control from tool box and do codins as

Adding connection string in database as


  
	
	
	  
	
	
  



Copy the source code as

1)Connection to database
 Dim strConn As String
        strConn = WebConfigurationManager.ConnectionStrings("ConnectionASPX").ConnectionString

        Dim Conn As New SqlConnection(strConn)


2)Declaring variables

Dim username As String
        Dim pwd As String
        Dim pName As String


3)Accesing user control with username and password
username = Login1.UserName
        pwd = Login1.Password
        pName = Login1.Name


4)Condition as

Conn.Open()


        Dim sqlUserName As String
        sqlUserName = "SELECT UserName,Password FROM UserName "
        sqlUserName &= " WHERE (UserName = @UserName"
        sqlUserName &= " AND Password = @Password)"

        Dim com As New SqlCommand(sqlUserName, Conn)
        com.Parameters.AddWithValue("@UserName", username)
        com.Parameters.AddWithValue("@Password", pwd)


        Dim CurrentName As String
        CurrentName = CStr(com.ExecuteScalar)

        If CurrentName <> "" Then
            Session("UserAuthentication") = username

            Response.Redirect("xxxx.aspx")
        Else
            Session("UserAuthentication") = ""
        End If


Thats it


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend