vb.net - Argument 'Expressions' cannot be converted into type "DBNull" -


i badly stuck error. when try call form (frmrecipe) menu.vb gives error on line trying maximum id recipe table, here code below

 function get_max_id() string         try             dim cmd new sqlcommand("select max(recipe_id) recipe", conn)             cmd.commandtype = commandtype.text             dim dr sqldatareader             dr = cmd.executereader             if dr.read                 return format(val(dr(0)).tostring + 1, "0000")             else                 return "0001"             end if         catch ex exception             msgbox(ex.message)         end try     end function 

recipe_id type of varchar in database

try this:

return format(val(dr(0).tostring) + 1, "0000") 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -