asp.net - Response.write only shows the first record from the database (this.session.sessionid) -


i've got problem past few days. explain short i've did. have table created in database called 'cart'. cart cointains: clientid, artical number, , quantity. in clientid, session.sessionid stored. in artical number 1012. , in quantity number 1 or 3.

what to, retrieve records, session.session id of user. work in page, first record of 4-5 records in cart table shown. think comes due problem looks this.session.sessionidand when found one, doesn't further that.

i've tried loop through query sessions is. won't let me loop because doesn't know for? if loop whole query outside of this:for (int = 0; < sessies.length; i++) show more records.. first records.. know stupid try can try..

looked on internet couldn't find solution this.

hope response somebody. gratefull.

used following code:

using (sqlconnection cn = new sqlconnection(configurationmanager.connectionstrings["garageconnectionstring"].tostring()))     {         string sessions = this.session.sessionid;                sqlcommand cmd = new sqlcommand("select * cart clientid='" + sessions + "'", cn);              cn.open();             sqldatareader rdr = cmd.executereader(commandbehavior.closeconnection);             rdr.read();               textbox1.text = rdr[2].tostring();               response.write("<br>" + ("sessie id "+rdr[1].tostring()));              response.write("<br>" + ("artikel nummer "+rdr[2].tostring()));              response.write("<br>" + ("aantal "+rdr[3].tostring()));               cn.close();      } 

sqldatareader advances next record in set: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read%28v=vs.110%29.aspx

call read() in loop, so:

using (sqlconnection cn = newsqlconnection(configurationmanager.connectionstrings["garageconnectionstring"].tostring())) {     string sessions = this.session.sessionid;            sqlcommand cmd = new sqlcommand("select * cart clientid='" + sessions + "'", cn);          cn.open();         sqldatareader rdr = cmd.executereader(commandbehavior.closeconnection);          while (rdr.read())         {            textbox1.text = rdr[2].tostring();              response.write("<br>" + ("sessie id "+rdr[1].tostring()));             response.write("<br>" + ("artikel nummer "+rdr[2].tostring()));             response.write("<br>" + ("aantal "+rdr[3].tostring()));          }          cn.close();  } 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -