Records in the Datasource not updated!
hi guys! I am trying to update a record in a datasource and it didnt work. there was no error produced but no changes in datasource. my code goes this way:
Public Sub UpdateCanvasser(ByVal newObj As Canvasser)
Dim cmdUpdate As New OleDbCommand()
cmdUPdate.Connection = CN
Dim mytrans As OleDbTransaction
CN.Open()
mytrans = CN.BeginTransaction
cmdUPdate.Transaction = mytrans
Try
cmdUpdate.CommandText = "Update Canvassers set Firstname=@Firstname," _
& " MI=@MI,Lastname=@Lastname,Address=@Address,ContactNo=@ContactNo " _
& " where CanvasserNO=@CanvasserNo"
cmdUpdate.Parameters.Add("@CanvasserNo", newObj.CanvasserNo)
cmdUpdate.Parameters.Add("@Firstname", newObj.Firstname)
cmdUpdate.Parameters.Add("@MI", newObj.MI)
cmdUpdate.Parameters.Add("@Lastname", newObj.Lastname)
cmdUpdate.Parameters.Add("@Address", newObj.Address)
cmdUpdate.Parameters.Add("@Contactno", newObj.ContactNo)
cmdUpdate.ExecuteNonQuery()
mytrans.Commit()
Catch ex As Exception
mytrans.Rollback()
MsgBox(ex.Message)
End Try
CN.Close()
End Sub
''''''''
a canvasser class is just a set of Property Procedures with no Method. i have assign values of each property already.
'''''''''''''''''''''''''''
Public Class Canvasser
Private m_canvasserNo As String
Private m_Firstname As String
Private m_MI As String
Private m_Lastname As String
Private m_address As String
Private m_contactNo As String
Public Sub New()
End Sub
Public Property CanvasserNo() As String
Get
CanvasserNo = m_canvasserNo
End Get
Set(ByVal Value As String)
If Not Value Is Nothing Then
m_canvasserNo = Value
Else
MsgBox("Invalid Null!")
End If
End Set
End Property
Public Property Firstname() As String
Get
Firstname = m_Firstname
End Get
Set(ByVal Value As String)
If Not Value Is Nothing Then
m_Firstname = Value
Else
MsgBox("Invalid null Fisttname")
End If
End Set
End Property
Public Property MI() As String
Get
MI = m_MI
End Get
Set(ByVal Value As String)
m_MI = Value
End Set
End Property
Public Property Lastname() As String
Get
Lastname = m_Lastname
End Get
Set(ByVal Value As String)
m_Lastname = Value
End Set
End Property
Public Property ContactNo() As String
Get
ContactNo = m_contactNo
End Get
Set(ByVal Value As String)
m_contactNo = Value
End Set
End Property
Public Property Address() As String
Get
Return m_address
End Get
Set(ByVal Value As String)
m_address = Value
End Set
End Property
End Class
...............................
what seems to be wrong?????