.net - Saving SQL results into a Lst? -
in database 1 user can have multiple order. want orders user , save in list.
this i'm doing now
public function getuserorders(byval userid integer) dataset dim sqlda new sqldataadapter dim ds new dataset dim mycommand new data.sqlclient.sqlcommand("sp_getuserorders", myconnection) ' mark command sproc mycommand.commandtype = commandtype.storedprocedure dim muserid new sqlparameter("@userid", sqldbtype.int) muserid.value = userid mycommand.parameters.add(muserid) try ' open connection , execute command myconnection.open() sqlda.selectcommand = mycommand sqlda.fill(ds) catch ex exception myconnection.close() end try return ds end function
but can't seem figure out how assign results list.
dim orderlist new listitemcollection() orderlist = getuserorders()
does not work, please help.
i got it.
i set list inside getuserorders function.
dim dr sqldatareader dim orderlist new listitemcollection() try ' execute command myconnection.open() dr = mycommand.executereader() if not dr.read() return nothing else while dr.read() orderlist .add(dr("ordercode")) end while end if dr.close() myconnection.close() end try
Comments
Post a Comment