Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to export query result to a text files with multiple records on it?
    text
    copied!<p>I'm trying to export certain fields from the query below to a Text file. The problem I'm facing is that only one record is showing up in the text file when I export it, I also want to append none query results to this text file. </p> <p>Also, some of the lines don't need to be repeated,</p> <pre><code> odbccon.Open(); OdbcCommand getcartons = new OdbcCommand("select * from wm242basd.chcart00 where chldno = '0010585567'", odbccon); OdbcDataAdapter adp = new OdbcDataAdapter(getcartons); OdbcDataReader odbcr = getcartons.ExecuteReader(); while (odbcr.Read()) { cartonnumber = odbcr["chcasn"].ToString() + " "; storenumber = odbcr["chstor"].ToString() + " "; weightlbs = odbcr["chacwt"].ToString(); } #region //Assign values to each String for Header Record - Type "A" constantA = "A"; fileidentifier = "ASN"; clientidentifier = "1111"; //Currently Pending on Call from Friday primaryscac = "1111"; //Currently Pending on Call from Friday dcidentifier = "ONT"; shipmentID = "0010585567 "; //This String could come from DataBase OR could be populated from TextBox by User masterBOL = " "; //This String could come from DataBase buildingID = " "; //Currently Pending on Call from Friday //Create Header Record - Type "A" w.WriteLine(constantA + fileidentifier + clientidentifier + primaryscac + dcidentifier + shipmentID + masterBOL + buildingID); //Assign values to each String for Load Record - Type "T" constantT = "T"; trailerclosedate = DateTime.Now.ToString("yyyyMMdd"); trailerclosetime = DateTime.Now.ToString("HHmm"); trailernumber = " "; //Pending on App Accessability OR could be populated from TextBox by user sealnumber = " "; expectedarrivaldate = DateTime.Now.AddDays(5).ToString("yyyyMMdd"); expectedarrivaltime = DateTime.Now.AddHours(3).ToString("HHmm"); trailerserialnumber = " "; carrier = " "; //Create Load Record - Type "T" w.WriteLine(constantT + trailerclosedate + trailerclosetime + trailernumber + sealnumber + expectedarrivaldate + expectedarrivaltime + trailerserialnumber + carrier); //Assign values to each String for Store Record - Type "B" constantB = "B"; deliverycarrierSCAC = " "; clientroute = " "; businesscode = " "; //storenumber = "1001 "; //This String should come from the DataBase clientbolnumber = " "; terminalcode = " "; deliverydays = "000"; deliverystarttime = " "; deliveryendtime = " "; carrierpro = " "; expecteddeliverydate = " "; //Create Store Record - Type "B" w.WriteLine(constantB + deliverycarrierSCAC + clientroute + businesscode + storenumber + clientbolnumber + terminalcode + deliverydays + deliverystarttime + deliveryendtime + carrierpro + expecteddeliverydate); //Assign values to each String for Store Record - Type "C" constantC = "C"; //cartonnumber = "1002333323569 "; //This String should come from DataBase //weightlbs = "0000000"; //This String could also come from DataBase cubicfeet = "0000000"; conveyable = "Y"; specialhandling = " "; cartonvalue = "00000000"; cartonretail = "00000000"; units = "0000"; //This String could also come from DataBase palletnumber = " "; //This String could also come from DataBase //Create Store Record - Type "C" w.WriteLine(constantC + cartonnumber + weightlbs + cubicfeet + conveyable + specialhandling + cartonvalue + cartonretail + units + palletnumber); //Assign values to each String for Store Record - Type "D" constantD = "D"; totalstorecartons = "0000023"; //This String should come from DataBase totalstoreweight = "000000000"; //This String could come from DataBase totalstorecubicfeet = "000000000"; //Create Store Record - Type "D" w.WriteLine(constantD + totalstorecartons + totalstoreweight + totalstorecubicfeet); //Assign values to each String for Store Record - Type "E" constantE = "E"; totaltrailercartons = "0000023"; //This String should come from DataBase totaltrailerweight = "000000000"; //This String could come from DataBase totaltrailercubicfeet = "000000000"; //Create Store Record - Type "E" w.WriteLine(constantE + totaltrailercartons + totaltrailerweight + totaltrailercubicfeet); #endregion //Maintenance and Close w.Flush(); w.Close(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload