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. VB.NET Selecting datatable for Login verification

VB.NET Selecting datatable for Login verification

Scheduled Pinned Locked Moved Visual Basic
tutorialcsharpdatabasemysql
7 Posts 3 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.
  • D Offline
    D Offline
    drexler_kk
    wrote on last edited by
    #1

    Hello all, I'm trying to create a user login verification for my Window Form Application using VB.NET 2003 connect with MySQL 5.0 database. When the login form load,I have load all the USERID,USERNAME and USERPASSWORD into a dataset and put into a datatable name"cashier" shown inside my code below:

    ObjConn = New OdbcConnection(Connect())
    ObjComm = New OdbcCommand("SELECT * FROM pos_cashier WHERE LocationCode='" & TerminalLocate & "'", ObjConn)

    ObjConn.Open()
    ObjAdapter.SelectCommand = ObjComm
    ObjAdapter.Fill(DS, "cashier")
    DT = DS.Tables("cashier")
    ObjConn.Close()

    Now I need someone can guide me how to select a row or column inside this datatable so I can check the user login name and password are same with what inside this cashier datatable which used to authorise user login. What I wish to do is something as follow: If textbox1.text = datatable.cashier.USERNAME Then If textbox2.text = datatable.cashier.USERPASSWORD Then UserloginSuccess = True Dim MainForm as new MainForm Me.Hide() MainForm.Show() Else Messagebox.show("Sorry,Wrong Password") End If Else Messagebox.Show("Sorry,Username not available on the system.") End IF Anyone can give me some help about selecting this datatable? Thank you for reading. Regards Drex

    N D 2 Replies Last reply
    0
    • D drexler_kk

      Hello all, I'm trying to create a user login verification for my Window Form Application using VB.NET 2003 connect with MySQL 5.0 database. When the login form load,I have load all the USERID,USERNAME and USERPASSWORD into a dataset and put into a datatable name"cashier" shown inside my code below:

      ObjConn = New OdbcConnection(Connect())
      ObjComm = New OdbcCommand("SELECT * FROM pos_cashier WHERE LocationCode='" & TerminalLocate & "'", ObjConn)

      ObjConn.Open()
      ObjAdapter.SelectCommand = ObjComm
      ObjAdapter.Fill(DS, "cashier")
      DT = DS.Tables("cashier")
      ObjConn.Close()

      Now I need someone can guide me how to select a row or column inside this datatable so I can check the user login name and password are same with what inside this cashier datatable which used to authorise user login. What I wish to do is something as follow: If textbox1.text = datatable.cashier.USERNAME Then If textbox2.text = datatable.cashier.USERPASSWORD Then UserloginSuccess = True Dim MainForm as new MainForm Me.Hide() MainForm.Show() Else Messagebox.show("Sorry,Wrong Password") End If Else Messagebox.Show("Sorry,Username not available on the system.") End IF Anyone can give me some help about selecting this datatable? Thank you for reading. Regards Drex

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      You can use DataTable.Select() method. It returns DataRow array.

      drexler_kk wrote:

      When the login form load,I have load all the USERID,USERNAME and USERPASSWORD into a dataset and put into a datatable name"cashier"

      It's bad design. Why don't you do user verification in the database when user clicks the login button ? When you are loading all the data to dataset on form load, your application will take long time to load when there are more number of users.

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      D 1 Reply Last reply
      0
      • N N a v a n e e t h

        You can use DataTable.Select() method. It returns DataRow array.

        drexler_kk wrote:

        When the login form load,I have load all the USERID,USERNAME and USERPASSWORD into a dataset and put into a datatable name"cashier"

        It's bad design. Why don't you do user verification in the database when user clicks the login button ? When you are loading all the data to dataset on form load, your application will take long time to load when there are more number of users.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        D Offline
        D Offline
        drexler_kk
        wrote on last edited by
        #3

        Sorry,can you give me some sample how should I used this DataTable.Select() method? Hello Navaneeth, I have try to change it to the following code but it doesn't work.

        For i = 0 to DT.Rows(i).Count - 1

        If Test =DT.Select("USERNAME='"& textbox1.text &"'")(i) Then
        If DT.Select("USERPASSWORD='" & textbox2.text &"'")(i) Then

          UserloginSuccess = True
          Dim MainForm as new MainForm
          Me.Hide()
          MainForm.Show()
          Exit For
        Else
          Messagebox.show("Sorry,Wrong Password!")
        End If
        

        Else
        Messagebox.show("Sorry,Username not available on ths system.")
        End If

        Next

        The code above can't work. Can you tell me how to fixed it? Besides,what do you mean by do the user verification in the database? You mean directly use a SELECT statement which depend on the username and userpassword from the server to check if the server have the username with the right password?? Thanks for reading everyone,hope to hear from you all again soon. Regards Drex

        N 1 Reply Last reply
        0
        • D drexler_kk

          Sorry,can you give me some sample how should I used this DataTable.Select() method? Hello Navaneeth, I have try to change it to the following code but it doesn't work.

          For i = 0 to DT.Rows(i).Count - 1

          If Test =DT.Select("USERNAME='"& textbox1.text &"'")(i) Then
          If DT.Select("USERPASSWORD='" & textbox2.text &"'")(i) Then

            UserloginSuccess = True
            Dim MainForm as new MainForm
            Me.Hide()
            MainForm.Show()
            Exit For
          Else
            Messagebox.show("Sorry,Wrong Password!")
          End If
          

          Else
          Messagebox.show("Sorry,Username not available on ths system.")
          End If

          Next

          The code above can't work. Can you tell me how to fixed it? Besides,what do you mean by do the user verification in the database? You mean directly use a SELECT statement which depend on the username and userpassword from the server to check if the server have the username with the right password?? Thanks for reading everyone,hope to hear from you all again soon. Regards Drex

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          If you look at the documentation[^], it would be easy.

          drexler_kk wrote:

          For i = 0 to DT.Rows(i).Count - 1

          No need of loop here. Select() returns a DataRow array.

          drexler_kk wrote:

          If Test =DT.Select("USERNAME='"& textbox1.text &"'")(i) Then

          This is wrong. Test =DT.Select("USERNAME='"& textbox1.text &"'"). Test should be DataRow array.

          drexler_kk wrote:

          Besides,what do you mean by do the user verification in the database? You mean directly use a SELECT statement which depend on the username and userpassword from the server to check if the server have the username with the right password??

          Yes. That would be faster than the method you are using. When user clicks on the login button, supply the user details entered to the database. Run a query to select the details. If everything is OK, proceed with login, else display error. Hope this helps

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

          D 1 Reply Last reply
          0
          • N N a v a n e e t h

            If you look at the documentation[^], it would be easy.

            drexler_kk wrote:

            For i = 0 to DT.Rows(i).Count - 1

            No need of loop here. Select() returns a DataRow array.

            drexler_kk wrote:

            If Test =DT.Select("USERNAME='"& textbox1.text &"'")(i) Then

            This is wrong. Test =DT.Select("USERNAME='"& textbox1.text &"'"). Test should be DataRow array.

            drexler_kk wrote:

            Besides,what do you mean by do the user verification in the database? You mean directly use a SELECT statement which depend on the username and userpassword from the server to check if the server have the username with the right password??

            Yes. That would be faster than the method you are using. When user clicks on the login button, supply the user details entered to the database. Run a query to select the details. If everything is OK, proceed with login, else display error. Hope this helps

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

            D Offline
            D Offline
            drexler_kk
            wrote on last edited by
            #5

            Hello Navaneeth, Yeah,thanks my friend. I have solve this problem by checking the site you provide. Thank You so much for the information and advice share me. Have a wonderful day. Regards Drex ;)

            N 1 Reply Last reply
            0
            • D drexler_kk

              Hello Navaneeth, Yeah,thanks my friend. I have solve this problem by checking the site you provide. Thank You so much for the information and advice share me. Have a wonderful day. Regards Drex ;)

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              Great ! glad to help.

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

              1 Reply Last reply
              0
              • D drexler_kk

                Hello all, I'm trying to create a user login verification for my Window Form Application using VB.NET 2003 connect with MySQL 5.0 database. When the login form load,I have load all the USERID,USERNAME and USERPASSWORD into a dataset and put into a datatable name"cashier" shown inside my code below:

                ObjConn = New OdbcConnection(Connect())
                ObjComm = New OdbcCommand("SELECT * FROM pos_cashier WHERE LocationCode='" & TerminalLocate & "'", ObjConn)

                ObjConn.Open()
                ObjAdapter.SelectCommand = ObjComm
                ObjAdapter.Fill(DS, "cashier")
                DT = DS.Tables("cashier")
                ObjConn.Close()

                Now I need someone can guide me how to select a row or column inside this datatable so I can check the user login name and password are same with what inside this cashier datatable which used to authorise user login. What I wish to do is something as follow: If textbox1.text = datatable.cashier.USERNAME Then If textbox2.text = datatable.cashier.USERPASSWORD Then UserloginSuccess = True Dim MainForm as new MainForm Me.Hide() MainForm.Show() Else Messagebox.show("Sorry,Wrong Password") End If Else Messagebox.Show("Sorry,Username not available on the system.") End IF Anyone can give me some help about selecting this datatable? Thank you for reading. Regards Drex

                D Offline
                D Offline
                darkelv
                wrote on last edited by
                #7

                IMO, you should try to select the user from table with the name and password without loading everybody into the dataset, ie Select * from pos_cashier Where LocationCode = @loc And UserName = @name And UserPassword = @password If you get a row, the password is valid, otherwise invalid.

                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