Click here to Skip to main content
16,020,182 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi everyone, i have doing simple program using vb.net 2010 and ms-access 2007 back-end. my problem is i am new for vb.net. i have two forms loginfrm and mainfrm. in loginfrm form i have 2 text box for username and password and 1 combobox for login as(login type like admin, user, maintainance...) after click login button mainfrm will display and it shows if i choose admin it shows "welcome Admin" , if i choose user it shows "welcome user" bla bla... on the lable in mainfrm. and my code is working for this. but, my problem is i didn't wont to use combobox. instead i wont to to inter only username and password and click login. when i clike login it compares the password and username field and write "welcome admin Or welcom User etc..." on the mainfrm. so how can i do this? i think you will help me.


thank you
with best regards!!!
Posted
Comments
Surendra Adhikari SA 11-Jun-13 8:10am    
you can certainly do this ...but
what have you tried so far?
can you give your related code snippet .
Beiniam 12-Jun-13 3:30am    
here is my code
Dim logcn As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\Login.mdb")
Dim logda As New OleDbDataAdapter()
Dim logdt As New DataTable()
' Dim co As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\Login.mdb")
Private ConnnectionString As String = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\Login.mdb"
Private dn As New DataSet()
Dim mypath = Application.StartupPath & "\Login.mdb"
Dim Password = ""
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\Login.mdb")
Dim cmd As OleDbCommand
Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\login.mdb")
Dim sql As String
' Dim CMD As OleDb.OleDbCommand
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

Dim sql = "SELECT Username,Password,LoginAs FROM UserLogin WHERE Username = '" & UsernameTextBox.Text & "' AND Password = '" & PasswordTextBox.Text & "' AND LoginAs ='" & LoginAsCombobox.Text & "'"
Dim log = "SELECT LoginAs FROM UserLogin"
Dim loginas = "SELECT LogionAs FROM UserLogin"
conn.Open()
cmd = New OleDbCommand(sql, conn)
Dim dr As OleDbDataReader = cmd.ExecuteReader

' Dim connString As String = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\login.mdb"
' conn.Close()

Try
If dr.Read = False Then
conn.Close()
MessageBox.Show("Authentication Failed...")
Else
conn.Close()
'With ERA_DMS_HOME
' .LoginAsToolStripMenuItem.Text = GetUserName()
' Dim logform As New LoginForm1

Dim homform As New ERA_DMS_HOME
homform.Show()
Me.Hide()
'logform.Hide()
' End With

End If
Catch ex As Exception
conn.Close()
MsgBox(ex.Message)
End Try
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If





End Sub

1 solution

Hii
You should create database table with three fields Username, Password and Category. CATEGORY field in using SQL query on 'LOGIN' button event and put condition as you want to put using data which is got from SQL Query..

Below linked tutorial will Help you..
http://www.daniweb.com/software-development/vbnet/threads/81418/login-form-in-vb.net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900