AccessShell
Member
- Joined
- Jun 14, 2016
- Messages
- 21
- Programming Experience
- 10+
I have been able to read records from the DB.  I have able to delete records from the DB.  Bit I cannot update a record to the DB.
My routine is as follows. The connection to DB has already been made. Forget the commented out code for now (BeginTrans, Commit, and Rollback). I'll worry about them later.
 
The " **CLIENT UPDATED SUCCESSFULLY**" message appears on my form. The "Catch ex As Exception" does not execute. The returned form show my changes, but the BD is not updated. When I restart the program, the updates do not show.
Can anyone explain what I did wrong?
Thanks
	
		
			
		
		
	
				
			My routine is as follows. The connection to DB has already been made. Forget the commented out code for now (BeginTrans, Commit, and Rollback). I'll worry about them later.
  
Public Sub UpdateClient()
        Dim strUpdateSQL As String
        Dim Msg As String
        Dim cmd As String
        Dim strI As String
        Dim strP As String
        Dim catCMD As OleDbCommand = con.CreateCommand()
 
        Try
            If Me.txtI.Text <> "" Then
                strI = Me.txtI.Text
            End If
            If Me.txtP.Text <> "" Then
                strP = Me.txtP.Text
            End If
 
            'trans = con.BeginTransaction
            strUpdateSQL = "UPDATE tblClient SET "
            strUpdateSQL = strUpdateSQL & "tblClient.I = '" & strI & "' ?
            strUpdateSQL = strUpdateSQL & "AND tblClient.P = '" & strP & "' "
            strUpdateSQL = strUpdateSQL & "WHERE (((tblClient.CatNbr)=" & gintCatSelectedItem & ") "
            strUpdateSQL = strUpdateSQL & "AND ((tblClient.ClientName)='" & gstrClientName & "')) "
 
            catCMD.CommandType = CommandType.Text
            catCMD.CommandText = strUpdateSQL
            catCMD.ExecuteNonQuery()
 
            'trans.Commit()
            catCMD.Dispose()
 
            Me.txtMessage.Text = " **CLIENT UPDATED SUCCESSFULLY**"
            blnRecipeDeleted = True
 
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            'trans.Rollback()
        End Try
 
End Sub
The " **CLIENT UPDATED SUCCESSFULLY**" message appears on my form. The "Catch ex As Exception" does not execute. The returned form show my changes, but the BD is not updated. When I restart the program, the updates do not show.
Can anyone explain what I did wrong?
Thanks
 
	 
 
		 
 
		 
 
		 
 
		