Question
I am using the following lines of code to update records based on rowid: here dsmain the dataset that i am using....
For j = 2 To AuditGrid.Rows - 1
If AuditGrid.ActiveCell.Row = j And AuditGrid.ActiveCell.Col = ColMark Then
Uvalue = Trim(AuditGrid.Cell(j, ColMark).Text)
da.UpdateCommand = New OracleCommand("update audit01 set user" & Trim(User) & "='" & Trim(Uvalue) & "' where audit01.rowid='" & Trim(AuditGrid.Cell(j, ColWRowid).Text) & "'")
End If
Next
da.Fill(DsMain, "AUDIT01")
da.Update(DsMain, "AUDIT01")
DsMain.AcceptChanges()
the problem is that the database is not being updated. what to do?
Solution
i have used the following lines of code and it now works perfectly fine...
If AuditGrid.ActiveCell.Row > 0 Then
Uvalue = Trim(AuditGrid.Cell(AuditGrid.ActiveCell.Row, ColMark).Text)
strQry = "update audit01 set user" & Trim(User) & "='" & Trim(Uvalue) & "' where rowidtochar( audit01.rowid)='" & AuditGrid.Cell(AuditGrid.ActiveCell.Row, ColWRowid).Text & "'"
da = New OracleDataAdapter(strQry, con)
da.Fill(DsMain)
DsMain.AcceptChanges()
MsgBox("Record Updated!!")
AuditGrid.Range(AuditGrid.ActiveCell.Row, ColMark, AuditGrid.ActiveCell.Row, ColMark).DeleteByRow()
End If
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow