Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am have a horrible time trying t

Status
Not open for further replies.

smithbr

MIS
May 29, 2003
85
US
I am have a horrible time trying to get this update to work correctly in my datagrid. I had it working yesterday and when i came in this morning it would not function right. I am trying to get the datagrid to add today's date (through lbltdatedisp label)to the paid column in my datagrid. I want it to only update those rows in the paid column that do not have a date already marked in them...this way I can keep track of when each row was marked paid. Below is my code....also, in the access db that it is connected to..the paid field is a text field , not a time/date so it should be able to compare "" to the field contents. Can anyone find a reason why this is not working...even if it looks good, i would like to know so I can move on to another part of the code and narrow it down that way. Thanks, Brent

Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click

If DsInvoice1.HasChanges Then
If MessageBox.Show("You are about to save all changes made in the Datagrid, Continue?", "InvoiceHistory", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then
'Da.Update(detail, "InvoiceHistory")
Try
Dim dr As DataRow
For Each dr In DsInvoice1.Tables(0).Rows
If dr.Item("Paid") = "" Then
dr.Item("Paid") = lbltdatedisp.Text
End If

Next
OleDbDataAdapter1.Update(DsInvoice1)


grdComm.Refresh()
Catch Ex As OleDbException
System.Diagnostics.Debug.Write(Ex.Message)
End Try
End If
End If
 
If the Paid column has not previously had a value is it possible that the value is NULL ?

If so, checking for an empty string ("") is not the same as checking for a NULL value. Try using:

If dr.Item("Paid") Is DBNull.Value Then
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top