the insert is working but the update isnt..

cjaymcmeans

Well-known member
Joined
Jan 12, 2005
Messages
85
Programming Experience
3-5
the insert is working.. im just dont get it why the update wont...
i need some help here... im kinda stuck...

Public Sub SaveRecords(ByVal XRow As DataTable, ByVal Id As String, ByVal fname As String, ByVal lname As String, ByVal DOB As Date, ByVal Ttype As Boolean, ByVal Indx As Integer)
Dim SaveRow As DataRow

If Ttype = True Then
SaveRow = XRow.NewRow
Equate(SaveRow, Id, fname, lname, DOB,
True)
MyDstUser.Tables("UserTable").Rows.Add(SaveRow)
Dim MySaveCom As OleDbCommand = SaveComm("insert into users (userid, userfname, userlname, userdate) values " & _
"(@UId, @FName, @LName, @DOB)")
MyAdpUser.InsertCommand = MySaveCom

Else

Dim EditRow As DataRow = MyDstUser.Tables("UserTable").Rows(Indx)
EditRow.BeginEdit()
Equate(EditRow, Id, fname, lname, DOB,
False
EditRow.EndEdit()
Dim MyEditCom As OleDbCommand = SaveComm("update users set userfname=@FName, userlname=@LName, userdate=@DOB " & _
"where userid=@UId")
MyAdpUser.UpdateCommand = MyEditCom
End If
Try
MyAdpUser.Update(MyDstUser, "UserTable")
MsgBox("Update Complete")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

i also tried this for getting the row
EditRow = MyDstUser.Tables("usertable").Select("userid='" & Id & "'")(0)

the procedure basically runs on the same subs as the insert...
the insert is working properly... why the update isnt is a big puzzle to me...

hope you guys can help me out...

 

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,052
Programming Experience
10+
Read the DW2 link in my signature; it'll really help with the data access. Right now youre writing by hand, a poor-mans version of some code that Visual Stuio can generate for you (and it's pretty good code too) in seconds
 
Top Bottom