While using the given below code showing one error. the error is: Operator '=' is not defined for type 'DBNull' and string "True". Help me to find a proper solution. Thank you.
Code :
cmd1.CommandText = "select * FROM attendance where academic_year='" & yearTextBox.Text & "' and School_Name='" & courseDropDownList.Text & "' and Class='" & semesterDropDownList.Text & "' and batch='" & batchDropDownList.Text & "' and hour='" & DropDownList6.Text & "' and date_present='" & TextBox1.Text & "'"
sdr1 = cmd1.ExecuteReader
While sdr1.Read
dr("student_name") = sdr1("student_name")
dr("rollnumber") = sdr1("roll_number")
dr("comment") = sdr1("comment")
Dim status As String = ""
If sdr1("present") = "True" Then // ***Error popup here***
status = "Present"
ElseIf sdr1("Absent") = "True" Then
status = "Absent"
ElseIf sdr1("od") = "True" Then
status = "OD"
End If
If sdr1("late") = "True" Then
dr("status_late") = ", Latecomer"
End If
dr("status") = status
dt.Rows.Add(dr)
dr = dt.NewRow
End While
sdr1.Close()
sdr1("Present").probably if its null,use.tostringthere.Isdbnullbefore using comparison operator.