Question Update Login Details to Database

ashveen

Member
Joined
Dec 15, 2013
Messages
14
Programming Experience
Beginner
C_P Form.JPG

Above shows my Change Password Form.
It shows the user type, username and passwords stored in my database.
I want to know how to add details from this form to the database (Add New Button)
and also want to know how to delete them (Delete Button)

here is my code, I tried a few of own but it didnt work. pls help me

VB.NET:
Public Class frm_Change_Password

    Private Sub frm_Change_Password_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move, Me.SizeChanged, Me.Shown
        Dim r As Rectangle = Me.Bounds
        r.Inflate(35, 35)
        frm_BG1.Bounds = r
    End Sub
    Private Sub Username_PasswordBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.Username_PasswordBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.Username_PasswordDataSet)
    End Sub

    Private Sub frm_Change_Password_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Owner = frm_BG1
        'TODO: This line of code loads data into the 'U_PDataSet.Usernames_Passwords' table. You can move, or remove it, as needed.
        Me.Username_PasswordTableAdapter.Fill(Me.Username_PasswordDataSet.Username_Password)
        IDTextBox.Enabled = False
        UserTypeTextBox.Enabled = False
        UsernameTextBox.Enabled = False
        PasswordTextBox.Enabled = False
    End Sub

    Private Sub KryptonButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton3.Click
        Me.Username_PasswordBindingSource.AddNew()
        IDTextBox.Enabled = True
        UserTypeTextBox.Enabled = True
        UsernameTextBox.Enabled = True
        PasswordTextBox.Enabled = True
    End Sub

    Private Sub KryptonButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton4.Click
        Me.Validate()
        Me.Username_PasswordBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.Username_PasswordDataSet)
    End Sub

    Private Sub KryptonButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton5.Click
        Me.Username_PasswordBindingSource.RemoveCurrent()
    End Sub
End Class
 
dataset.JPG

here is my dataset, the rightside panel show the Update and Delete queries? pls tell me what should i input there??
 
Please don't post unless you have something relevant to add. We are all in different time zones and some of us even work and sleep sometimes. We will answer your questions if and when we can.

Firstly, I would like to point out a serious flaw in your design. As you may have seen, almost all forms that create new user records with a password ask you to enter the password twice. That's because they will also mask the password for security and, if the user can't see the password, it's possible that they might not type what they intend. If the user makes a typo and you don't require them to confirm the password then they will have locked themselves out from the word go.

As for your question, I'm confused as to why those commands weren't generated automatically. Your table appears to have a primary key and I would think that only the lack of a PK would prevent those commands being created by the wizard. Was that PK always there or did you add it after generating the DataSet?
 
Please don't post unless you have something relevant to add. We are all in different time zones and some of us even work and sleep sometimes. We will answer your questions if and when we can.

Firstly, I would like to point out a serious flaw in your design. As you may have seen, almost all forms that create new user records with a password ask you to enter the password twice. That's because they will also mask the password for security and, if the user can't see the password, it's possible that they might not type what they intend. If the user makes a typo and you don't require them to confirm the password then they will have locked themselves out from the word go.

As for your question, I'm confused as to why those commands weren't generated automatically. Your table appears to have a primary key and I would think that only the lack of a PK would prevent those commands being created by the wizard. Was that PK always there or did you add it after generating the DataSet?

I'm sorry for my ego.
well, I haven't encrypted the Password Input Box, so anybody with admin privileges can access it. Well yes after generating the dataset, I assigned the primary key. But i didnt get the DeleteCommand's and UpdateCommand's CommandText. Can you please tell me what should I do to make them work.
Thank You!
 
If you did create the PK after generating the DataSet then that's your issue. You need to re-run the configuration wizard, which you can do using a button at the top of the Data Sources window, to add the missing commands. I'm not sure whether they will be added to the exiting adapter now or not but, if not, you can simply delete the DataTables in the DataSet designer and then let the wizard re-add them. The PK is required because that what's used to identify which record to update or delete. Without it, a record can't identified so it can't be updated or deleted, so no UpdateCommand or DeleteCommand is created.
 
If you did create the PK after generating the DataSet then that's your issue. You need to re-run the configuration wizard, which you can do using a button at the top of the Data Sources window, to add the missing commands. I'm not sure whether they will be added to the exiting adapter now or not but, if not, you can simply delete the DataTables in the DataSet designer and then let the wizard re-add them. The PK is required because that what's used to identify which record to update or delete. Without it, a record can't identified so it can't be updated or deleted, so no UpdateCommand or DeleteCommand is created.
thank you very much, okay I'll try that!
 
Back
Top