Operator '=' is not defined for type 'DBNull' and string "0".

  • Thread starter Thread starter htcting
  • Start date Start date
H

htcting

Guest
i face this issue on my code can some one help me....

Private Sub dgvData_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgvData.CellFormatting
Dim dgv As DataGridView = Me.dgvData
For i As Integer = 0 To dgv.Rows.Count - 1
For ColNo As Integer = 1 To 7
If Not dgv.Rows(i).Cells(ColNo).Value Is DBNull.Value Then
dgv.Rows(i).Cells(ColNo).Style.BackColor = Color.LightCyan
End If
Next
Next

For i As Integer = 0 To Me.dgvData.Rows.Count - 1
If Me.dgvData.Rows(i).Cells(3).Value = "0" Then
Me.dgvData.Rows(i).DefaultCellStyle.ForeColor = Color.Maroon
End If
Next

End Sub


Private Sub txtbarcode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbarcode.TextChanged
cn.Open()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter

da = New OleDbDataAdapter("SELECT * FROM checker WHERE cbcid like '%" & txtbarcode.Text & "%'", cn)
da.Fill(dt)

dgvData.DataSource = dt.DefaultView
cn.Close()
End Sub

Continue reading...
 
Back
Top