Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Login User

Login User

Scheduled Pinned Locked Moved Visual Basic
helpregex
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmad Rifai Yusuf
    wrote on last edited by
    #1

    :)Hallo everybody,,,! Please anybody if can help me...! I have problem with my login user code .., If the user type the wrong password the messagebox couldn't appear "Pasword does not match with username", but the messagebox appeared is "Username does not exist" asa same as we type the wrong username. THe code is written below : Dim ds As New DataSet Dim dt As DataTable Dim dr As DataRow Dim username As String = Me.txtUserName.Text Dim password As String = Me.txtPassword.Text Dim strSql As String = "SELECT * FROM users where username='" + username + "' and password='" + password + "'" Dim oleConn As New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=data\persedkont.mdb") Dim oleDa As New OleDb.OleDbDataAdapter(strSql, oleConn) oleDa.Fill(ds) dt = ds.Tables(0) If (dt.Rows.Count = 0) Then MessageBox.Show(username + " does not exists!", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Else dr = dt.Rows(0) Dim pass As String = dr(2).ToString Dim userId As String = dr(1).ToString If (dt.Rows.Count = 0) And password <> pass Then MessageBox.Show("Password does not match with username.", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Me.clearForm() Else If password = pass Then Me.clearForm() Me.Close() End If End If End If 'MessageBox.Show(strSql) Try Catch ex As Exception MessageBox.Show("Wrong UserId or Password") End Try Thank's verymuch for help. Best Regards, Ahmad Rifai Yusuf

    M M A 3 Replies Last reply
    0
    • A Ahmad Rifai Yusuf

      :)Hallo everybody,,,! Please anybody if can help me...! I have problem with my login user code .., If the user type the wrong password the messagebox couldn't appear "Pasword does not match with username", but the messagebox appeared is "Username does not exist" asa same as we type the wrong username. THe code is written below : Dim ds As New DataSet Dim dt As DataTable Dim dr As DataRow Dim username As String = Me.txtUserName.Text Dim password As String = Me.txtPassword.Text Dim strSql As String = "SELECT * FROM users where username='" + username + "' and password='" + password + "'" Dim oleConn As New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=data\persedkont.mdb") Dim oleDa As New OleDb.OleDbDataAdapter(strSql, oleConn) oleDa.Fill(ds) dt = ds.Tables(0) If (dt.Rows.Count = 0) Then MessageBox.Show(username + " does not exists!", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Else dr = dt.Rows(0) Dim pass As String = dr(2).ToString Dim userId As String = dr(1).ToString If (dt.Rows.Count = 0) And password <> pass Then MessageBox.Show("Password does not match with username.", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Me.clearForm() Else If password = pass Then Me.clearForm() Me.Close() End If End If End If 'MessageBox.Show(strSql) Try Catch ex As Exception MessageBox.Show("Wrong UserId or Password") End Try Thank's verymuch for help. Best Regards, Ahmad Rifai Yusuf

      M Offline
      M Offline
      Mohammad Dabaan
      wrote on last edited by
      #2

      hi man i dont know, u can make a select statement to select justonly the password of the entered user name, and then compare it with the entered password ..... if doesnt match give the message box with a sentence u want ...... Thanks alot Hamody

      1 Reply Last reply
      0
      • A Ahmad Rifai Yusuf

        :)Hallo everybody,,,! Please anybody if can help me...! I have problem with my login user code .., If the user type the wrong password the messagebox couldn't appear "Pasword does not match with username", but the messagebox appeared is "Username does not exist" asa same as we type the wrong username. THe code is written below : Dim ds As New DataSet Dim dt As DataTable Dim dr As DataRow Dim username As String = Me.txtUserName.Text Dim password As String = Me.txtPassword.Text Dim strSql As String = "SELECT * FROM users where username='" + username + "' and password='" + password + "'" Dim oleConn As New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=data\persedkont.mdb") Dim oleDa As New OleDb.OleDbDataAdapter(strSql, oleConn) oleDa.Fill(ds) dt = ds.Tables(0) If (dt.Rows.Count = 0) Then MessageBox.Show(username + " does not exists!", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Else dr = dt.Rows(0) Dim pass As String = dr(2).ToString Dim userId As String = dr(1).ToString If (dt.Rows.Count = 0) And password <> pass Then MessageBox.Show("Password does not match with username.", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Me.clearForm() Else If password = pass Then Me.clearForm() Me.Close() End If End If End If 'MessageBox.Show(strSql) Try Catch ex As Exception MessageBox.Show("Wrong UserId or Password") End Try Thank's verymuch for help. Best Regards, Ahmad Rifai Yusuf

        M Offline
        M Offline
        Mandar Patankar
        wrote on last edited by
        #3

        HAve u checked whether the table has any rows in it because the Message box should pop only when the table rows are 0 and also when you are executing the fill method of dataadpater also aspecify the TAble name and use the table insted of index while retrieving the populated table I think this should answer all your queries Mandar Patankar MCP

        1 Reply Last reply
        0
        • A Ahmad Rifai Yusuf

          :)Hallo everybody,,,! Please anybody if can help me...! I have problem with my login user code .., If the user type the wrong password the messagebox couldn't appear "Pasword does not match with username", but the messagebox appeared is "Username does not exist" asa same as we type the wrong username. THe code is written below : Dim ds As New DataSet Dim dt As DataTable Dim dr As DataRow Dim username As String = Me.txtUserName.Text Dim password As String = Me.txtPassword.Text Dim strSql As String = "SELECT * FROM users where username='" + username + "' and password='" + password + "'" Dim oleConn As New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=data\persedkont.mdb") Dim oleDa As New OleDb.OleDbDataAdapter(strSql, oleConn) oleDa.Fill(ds) dt = ds.Tables(0) If (dt.Rows.Count = 0) Then MessageBox.Show(username + " does not exists!", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Else dr = dt.Rows(0) Dim pass As String = dr(2).ToString Dim userId As String = dr(1).ToString If (dt.Rows.Count = 0) And password <> pass Then MessageBox.Show("Password does not match with username.", "Login Fail", MessageBoxButtons.OK, MessageBoxIcon.Error) Me.clearForm() Else If password = pass Then Me.clearForm() Me.Close() End If End If End If 'MessageBox.Show(strSql) Try Catch ex As Exception MessageBox.Show("Wrong UserId or Password") End Try Thank's verymuch for help. Best Regards, Ahmad Rifai Yusuf

          A Offline
          A Offline
          albCode
          wrote on last edited by
          #4

          Hi, I wanna help you handling... so for username adn password i will show u my idea (maybe easy one) If me.txtUserName.Text<>"john" Then msgbox("the user " & me.txtUserName.Text & "doesnt exist") ElseIf me.txtPasswor.Text<>"kenedy" Then msgbox("password incorrect") EndIf this is a simple code for username and password for login without using DB

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups