Hi there, having a bit of a problem with one of my SQL statements.
I'm trying to get the table to update the password field.
Basically the user logs in on one form and then the form visibility is set to false.
The variables for that form are set to Public shared, so i can use then on this form. In this case they are frmlogin.staffid and frmlogin.level
I've tried copying and pasting the SQL into access and it works fine, so not too sure whats going wrong.
The exact error i get is in the title.
The other fields in the table are not relevant (Forename and Surname) so i haven't included them in the query.
Can anyone spot anything wrong with it?Code:'If the new password textboxes don't contain the same password then clear them and get them to do it again. If txtnewpass.Text = txtnewpass1.Text Then Dim dbCommand As OleDbCommand = New OleDbCommand 'create and open the connection object dbconnection = New OleDbConnection(strconnection) dbconnection.Open() Using dbCmd As New OleDbCommand dbCommand.Connection = dbconnection 'Set the SQL up for updating the staff table dbCommand.CommandText = "UPDATE staff SET Password = @newpassword WHERE staff_ID = @Staff_ID AND [Level] = @level AND Password = @oldpass" dbCommand.CommandType = CommandType.Text 'Add in the new / updated values With dbCommand.Parameters .AddWithValue("@newpassword", txtnewpass.Text) .AddWithValue("@level", frmLogin.level) .AddWithValue("@staff_ID", frmLogin.StaffID) .AddWithValue("@oldpass", txtoldpass.Text) End With ' and finally execute the SQL to update the record in customers table Try dbCommand.ExecuteNonQuery() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try End Using dbconnection.Close() 'Give user feedback lblaction.Text = "Password successfully changed" Else MessageBox.Show("Passwords do not match") cleartextboxes(grpchangepass) End If
Thanks in advance.




Reply With Quote