Resources » Code Snippets » Active Directory

Login Form


Posted Date: 11-Mar-2008  Last Updated:   Category: Active Directory    
Author: Member Level: Gold    Points: 10



Login Form




Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
' Try
'If smode = "N" Then
If txtUsername.Text = "" Then
MsgBox("Enter UserName !..", MsgBoxStyle.Information)
txtUsername.Focus()
Exit Sub
End If
If txtPassword.Text = "" Then
MsgBox("Enter Password!..", MsgBoxStyle.Information)
txtPassword.Focus()
Exit Sub
End If

If btnLogin.Text = "Create" Then
cmd = New SqlClient.SqlCommand("select USERNAME from LOGIN where USERNAME= ' " & txtUsername.Text & " '", conn)
sda = New SqlDataAdapter(cmd)
Dim ds As New DataSet()
sda.Fill(ds, "LOGIN")

If ds.Tables(0).Rows.Count = 0 Then
cmd1 = New SqlCommand("insert into Login Values(' " & txtUsername.Text & " ',' " & txtPassword.Text & " ')", conn)
cmd1.ExecuteNonQuery()
MsgBox("New Account Created..", MsgBoxStyle.Information)
txtUsername.Text = ""
txtPassword.Text = ""
LinkLabel1.Enabled = True
btnLogin.Text = "Login"
btnCancle.Text = "&Close"
Else
MsgBox("UserName Already Exists...", MsgBoxStyle.Information)
txtUsername.Text = ""
txtUsername.Focus()
End If
Else
cmd = New SqlCommand("Select USERNAME from LOGIN where USERNAME = ' " & txtUsername.Text & " '", conn)
sda = New SqlDataAdapter(cmd)
Dim ds As New DataSet()
ds.Clear()
sda.Fill(ds, "LOGIN")

If ds.Tables(0).Rows.Count = 0 Then
MsgBox("Invalid UsrName..", MsgBoxStyle.Information)
txtUsername.Text = ""
txtPassword.Text = ""
txtUsername.Focus()
Exit Sub
ElseIf ds.Tables(0).Rows.Count <> 0 Then
cmd = New SqlCommand("Select USERNAME,PASSWORD from LOGIN where USERNAME = ' " & txtUsername.Text & " ' and PASSWORD =' " & txtPassword.Text & " ' ", conn)
sda = New SqlDataAdapter(cmd)
ds.Clear()
sda.Fill(ds, "LOGIN")
If ds.Tables(0).Rows.Count = 0 Then
MsgBox("Invalid Password", MsgBoxStyle.Information)
txtPassword.Text = ""
txtPassword.Focus()
Exit Sub
Else
'MsgBox("OK")
'Dim p As New PRO
'p.Show()
'Me.Hide()

'Dim mn As New Menu
'mn.Show()
'Me.Hide()
Dim p As New P1
p.Show()
Me.Hide()
End If
End If
End If

'Catch ex As Exception
' MsgBox(ex.Message)
'End Try

End Sub



Did you like this resource? Share it with your friends and show your love!

Responses to "Login Form"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India