C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Active Directory »

Login Form


Posted Date: 11 Mar 2008    Resource Type: Code Snippets    Category: Active Directory
Author: gavasMember Level: Gold    
Rating: 1 out of 5Points: 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





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to decrypt encrypted text or password in c#.net?
Previous Resource: Go Back to Previous Page
Return to Discussion Resource Index
Post New Resource
Category: Active Directory


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use