sql - VB.net Passing parameter to function with a stored procedure -
i trying call function populate datatable, not working , lost. getting function error. function doesn't return value on code paths. here's code please thank you.
protected sub search_click(sender object, e eventargs) handles search.click strpartnumber = txtpartnumber.text dim ct datatable = me.getcompanyinfo(strpartnumber, "none") dvcommon.datasource = ct dvcommon.databind() end sub private function getcompanyinfo(byref partnumber string, byref version string) datatable dim constr string = configurationmanager.connectionstrings("defaultconnection").connectionstring using con new sqlconnection(constr) using cmd new sqlcommand("spcommoninfo") cmd.connection = con cmd.commandtype = commandtype.storedprocedure cmd.parameters.addwithvalue("@partnumber", partnumber) cmd.parameters.addwithvalue("@version", version) using sda new sqldataadapter(cmd) dim ct new datatable() sda.fill(ct) end using end using end using end function
as far see method getcompanyinfo returns datatable as datatable no in code returning one.
you should return datatable have filled
return ct your function code should be
private function getcompanyinfo(byref partnumber string, byref version string) datatable dim constr string = configurationmanager.connectionstrings("defaultconnection").connectionstring using con new sqlconnection(constr) dim ct new datatable() using cmd new sqlcommand("spcommoninfo") cmd.connection = con cmd.commandtype = commandtype.storedprocedure cmd.parameters.addwithvalue("@partnumber", partnumber) cmd.parameters.addwithvalue("@version", version) using sda new sqldataadapter(cmd) sda.fill(ct) end using end using end using return ct end function
Comments
Post a Comment