mysql - retrieving null date from database to vb.net -
i having problem in recovering null date database datepicker in vb.net.
i able save datein mysql null value can't retrieve datepicker.
i tried code doesn't work.
if reader.isdbnull(0) return else refdate.text = reader.getstring("refdate") end if
my code retrieving is
try if e.rowindex >= 0 dim row datagridviewrow row = me.datagridview1.rows(e.rowindex) forid.text = row.cells("id").value.tostring try connection.open() dim sel string sel = "select * recordtracker id ='" & forid.text & "'" com = new mysqlcommand(sel, connection) reader = com.executereader while reader.read cancel.show() clear.hide() rdate.enabled = false rfromtbx.enabled = false doctype.dropdownstyle = comboboxstyle.dropdown id.text = reader.getint32("id") doctype.text = reader.getstring("type_of_document") itemtbx.text = reader.getstring("items") rfromtbx.text = reader.getstring("received_from") rdate.text = reader.getstring("received_date") remarks.text = reader.getstring("remarks") margnote.text = reader.getstring("marginal_note") reftotbx.text = reader.getstring("referred_to") acttaken.text = reader.getstring("action_taken") 'refdate.text = reader.getstring("refdate") 'if reader.read() if reader.isdbnull(0) return else refdate.text = reader.getstring("refdate") end if delete.show() ' end if end while catch ex exception msgbox(ex.message) end try
any appreciated.
for future use, answer needed asker.
reader.isdbnull(0)
gets value of index 0 presume refdate
not in first index.
using reader.getstring("refdate")
gets string
value; therefore, when retrieving null
value, returns error better use isdbnull(reader("refdate"))
check if field null or not. string value, can use reader("refdate").tostring
Comments
Post a Comment