How to change password using access as database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dexter delleva
    New Member
    • Feb 2011
    • 12

    How to change password using access as database?

    please can anyone help me?
    im currently working in a project and i already made a code for the login, the only thing is that i dont know how to update the records(Usernam e/Password) in access using VB 2010. well i can update by manually changing the content of my table but i like to have it change using an interface in my vb named Manage account...

    thank you in advance.
  • timr30017
    New Member
    • May 2010
    • 9

    #2
    Hey!

    I don't know if you mean you want to change the username/passwords that are or can be integrated with Access by enabling security or if you have a table that contains username and passwords.

    If it is the later case then you should be able to do something like so by adding a DataBindingSour ce to your form you use to Manage account.

    Code:
     Me.SettingsBindingSource.MoveFirst()
                    Me.SettingsBindingSource.RemoveCurrent()
                    Me.Validate()
                    Me.SettingsBindingSource.EndEdit()
                    Me.TableAdapterManager.UpdateAll(Me.RecruitingDataSet)
                    Me.SettingsBindingSource.AddNew()
    You will just need to modify this code a bit above to find the correct user then delete their username/password and add it back using the Addnew method.

    Then be sure to do this:

    Code:
     Me.Validate()
                    Me.SettingsBindingSource.EndEdit()
                    Me.TableAdapterManager.UpdateAll(Me.RecruitingDataSet)
                Else
                    MessageBox.Show("The passwords do not match - please try again.")
                End If

    Comment

    • dexter delleva
      New Member
      • Feb 2011
      • 12

      #3
      i do have a table that contains username and password. and there are 3 default username and password that can be use to login. if i were the Admin(one of the user) i can login using the default password for the username admin and at the same time to enforce security i can update or change may accounts password.

      thanks for your reply. I'll try this.

      Comment

      • dexter delleva
        New Member
        • Feb 2011
        • 12

        #4
        im confuse, how can i compare the if statement in the code directly to password only.
        " if me.validate () = ? then
        Me.SettingsBind ingSource.EndEd it() Me.TableAdapter Manager.UpdateA ll(Me.Recruitin gDataSet)"

        is my logic right?? sorry for not understanding well, im not really good in coding^^

        Comment

        • timr30017
          New Member
          • May 2010
          • 9

          #5
          No what you want to find and compare is the record you want to change so if say the user name is admin you will do something like the following. But the trick I used was to put a textbox field on the form. IF you don't want the user to see it so your app stays all 'pretty' just either change all the colors to the same as the form's background OR hide it (send to back) behind another control on the form. Then:

          let's say your admin name is displayed in textbox1 and your hidden textbox is called textbox2 - oh and use one more to put the new password into or ever how you might want to do this.

          Code:
          if textbox1.text = textbox2.text then
                          Me.SettingsBindingSource.RemoveCurrent()
                          Me.Validate()
                          Me.SettingsBindingSource.EndEdit()
                          Me.TableAdapterManager.UpdateAll(Me.[B][U]YourDataSourceNameHERE[/U][/B])
          end if
          ' now add your new record back
                  Me.SettingsBindingSource.AddNew()
                  textbox2.text = "adminuser"        
                  textbox3.text = "mynewpassword"
                  Me.Validate()
                  Me.SettingsBindingSource.EndEdit()
                  Me.TableAdapterManager.UpdateAll(Me.[B][U]YourDataSourceNameHERE[/U][/B])
          This isn't the prettiest way to do this but this is exactly how I hide what is going on behind the scenes when I encrypt a username, product key, and activation code when the user actually activates my software.

          It is kind of quirky but this is what I came up with late one night after working on some code to do ALL the above for like 9 hrs.

          Comment

          • timr30017
            New Member
            • May 2010
            • 9

            #6
            oh i forgot one thing. Instead of just

            END IF

            do

            ELSE ' this not the right record
            settingsbinding source.movenext ()
            END IF

            But now thinking about it you will want to use a while statement or some kind of loop to ensure you get to the right record you want to change.

            Comment

            • dexter delleva
              New Member
              • Feb 2011
              • 12

              #7
              does the "Me.YourDataSou rceNameHERE" signifies the dataadapter??
              im going to try this... btw ive been working on a code i found on other sources and tried it but cant seem to figure out whats wrong.

              this is the code:

              Dim i, rwno As Integer
              Dim colname As String
              Dim value As Object
              colname = "Password"
              rwno = 0
              value = TextBox3.Text
              Try

              ''Update the column in the Student table. _Museum_finalDa taSet11.Tables( 0).Rows(1).Item (columnName:=co lname) = value
              'Update the Student table in the testdb database.
              i = LoginTableAdapt er1.Update(_Mus eum_finalDataSe t11)
              Catch ex As Exception
              MessageBox.Show (ex.Message)
              End Try
              'Displays number of rows updated.
              MessageBox.Show ("no of rows updated=" & i)

              Comment

              • dexter delleva
                New Member
                • Feb 2011
                • 12

                #8
                does the "Me.YourDataSou rceNameHERE" signifies the dataadapter??
                im going to try this... btw ive been working on a code i found on other sources and tried it but cant seem to figure out whats wrong.

                message box appears saying that "there is no row at position 1" but the password column in my table is row 1.

                this is the code:
                [LIST][*]Dim i, rwno As Integer[*] Dim colname As String[*] Dim value As Object[*] colname = "Password"[*] rwno = 0[*] value = TextBox3.Text[*] Try[*] [*] ''Update the column in the Login table.
                • _Museum_finalDa taSet11.Tables( 0).Rows(1).Item (columnName:=co lname) = value
                • 'Update the login table in the Museum-final database.
                • i = LoginTableAdapt er1.Update(_Mus eum_finalDataSe t11)
                • Catch ex As Exception
                • MessageBox.Show (ex.Message)
                • End Try
                • 'Displays number of rows updated.

                MessageBox.Show ("no of rows updated=" & i)

                Comment

                • dexter delleva
                  New Member
                  • Feb 2011
                  • 12

                  #9
                  i really find it hard to understand.. im sorry. but i'll keep trying until i got it right.^^ tnx

                  Comment

                  • dexter delleva
                    New Member
                    • Feb 2011
                    • 12

                    #10
                    finally found a way how to change the password... tnx!

                    Comment

                    Working...