seano
Active member
- Joined
- Jul 4, 2012
- Messages
- 32
- Programming Experience
- Beginner
For some reason there is an error in my SQL Update statement i have done this a million times before so i dont know why it isn't working. I have a Class called clsDateManagement where all my Code to do with Database is stored. here is the code,
Change Password form:
in clsDataManagement the update function
Please help, Thanks for your time.
Change Password form:
VB.NET:
Public Class ChangePassword
Public DataManagement As New clsDataManagement("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=POSDatabase.accdb")
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
Try
Dim DSUser As New DataSet
DSUser = DataManagement.SelectObjects("Employees", "Where Password= '" & txtpassword.Text & "'")
If DSUser.Tables(0).Rows.Count = 1 Then
If txtnewpasswordconfirm.Text = txtnewpassword.Text Then
'DataManagement.Update("Employees", DSUser.Tables(0).Rows(0).Item("EmployeeID"), "Password= '" & txtnewpassword.Text & "'", "EmployeeID")
DataManagement.Update("UPDATE Employees Set Password= '1234' Where EmployeeID = 1", 0, "", "")
Login.txtUsername.Select()
Login.txtUsername.Focus()
Me.Close()
Else
MsgBox("New Passwords Dont Match!", MsgBoxStyle.Critical, "POS System")
txtnewpasswordconfirm.Clear()
txtnewpassword.Clear()
txtnewpassword.Select()
txtnewpassword.Focus()
End If
Else
MsgBox("Login Incorrect!", MsgBoxStyle.Critical, "POS System")
txtpassword.Clear()
txtnewpasswordconfirm.Clear()
txtnewpassword.Clear()
txtpassword.Select()
txtpassword.Focus()
End If
Catch ex As Exception
MsgBox("Cant Connect to DataBase!", MsgBoxStyle.Critical, "POS System")
End Try
End Sub
in clsDataManagement the update function
VB.NET:
Public Function Update(ByVal tableName As String, ByVal id As Integer, ByVal updateClause As String, ByVal IDFieldName As String) As String
Try
Dim myOleDbConnection As New OleDbConnection(connectionString)
' Get the result as a Table - one record per object
myOleDbConnection.Open()
Dim UpdateSQL As String = "UPDATE " & tableName & " SET " & updateClause & " WHERE (" & IDFieldName & " = " & id & ")"
Dim myCommand As New OleDbCommand(tableName, myOleDbConnection)
myCommand.ExecuteNonQuery()
myOleDbConnection.Close()
Catch ex As Exception
Return ex.ToString
End Try
Return ""
End Function
Please help, Thanks for your time.