How to return multiple records using while loop?


i able return multiple records method below. using while loop extract multiple records current output showing 1 record. 

i tried using <list> string , return output list seem working while loop. 

please advice.  thank you. 

public string teststory()          {              string result = "";                using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["##"].connectionstring))              {                  con.open();                    using (sqlcommand command = new sqlcommand("####", con))                  {                      sqldatareader reader = command.executereader();                      while (reader.read())                      {                          string title = (reader.getstring(0));                            string content = (reader.getstring(1));                                                 result = title + content;  						                          //return result;                      }                  }                  return result;              }          }


missy ...
   result = title + content;    change      result =    result + title + content;  or   use list ..try  list<string> result = new list<string>();  result.add("your string")  



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

RFC_ERROR_SYSTEM_FAILURE with SAP ECC 6 Unicode

C# System.Data.Common DbCommand and getting Datasets from Oracle