Hello, I am having a real problem figuring out why this code is not working in my vb.net project. I am tryig to get todays date, which is dispalyed in lbltdatedisp to insert into the paid column only if teh field is blank...in other words, i want to be able to update it and mark the date on day...go through and add a few more records, and mark those with a different date withut changing the date of those mark previously. In my access database the paid column is set as text so I did not think it whoud be a problem comparing it via ="" ( as you will see below in my code). Can anyone help me out with this... really need to have this working by the end of the day and can not see what I need to do...Thanks in advance for everything.
the error message i keep getting is An unhandled exception of type System.InvalidCastException occurred in microsoft.visualbasic.dll
Additional information: Operator is not valid for type DBNull and string "".
and it is referencing the line :
Code:
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
End Sub
the error message i keep getting is An unhandled exception of type System.InvalidCastException occurred in microsoft.visualbasic.dll
Additional information: Operator is not valid for type DBNull and string "".
and it is referencing the line :
Code:
If dr.Item("Paid") = "" Then