vb.net - Operator '=' is not defined for type 'DBNull' and type 'Integer' -
i've been struggling past few hours , still can't head round 1 . issue having when has been admitted database updates giving them bedid , when try , discharge them can't seem set bedid (in database) nothing . issue need able admit , discharge many people can.
sub dis1_click(byval s object, byval e eventargs) handles dis1.serverclick dim time string = now().tostring("dd-mm-yyyy hh:mm:ss") sql = "update allocation set bedid = null , dischargedate =" + "'" + time + "'" + " bedid = 1 " cmd = new odbccommand(sql, cn) cmd.executenonquery() end sub sub bedcheck1() if r("bedid") = "" else if r("bedid") = 1 ba = s & "<tr><td>" & r("surname") & "</td>" & "<td>" & r("forename") & "/<td>" & "<td>" & r("admitdate") & "</td>" & "<td>" & r("dischargedate") & "</td>" & "<td>" & r("comments") & "</td></tr>" end if end if end sub
thanks!
you need dbnull-check before read value:
if not isdbnull(r("bedid")) if r("bedid") = "" else if r("bedid") = 1 ba = s & "<tr><td>" & r("surname") & "</td>" & "<td>" & r("forename") & "/<td>" & "<td>" & r("admitdate") & "</td>" & "<td>" & r("dischargedate") & "</td>" & "<td>" & r("comments") & "</td></tr>" end if end if
note dbnull special case , need use isdbnull-function prevent error
Comments
Post a Comment