Friday, January 25, 2019

How to order alphabetically EXCEPT for one item?

SELECT name,CreatedOn
FROM categories
ORDER BY name ASC, CreatedOn DESC

an explicit CASE expression, which is standard SQL and will work in any database system, is better --

ORDER
    BY CASE WHEN name = 'Other'
            THEN 1 -- last
            ELSE 0 -- first
        END ASC
     , CreatedOn DESC

Wednesday, January 9, 2019

Run another exe, with arguments, and capture output...

       
         Exe Console Application Output is  New Order  created Successfully.  
     
       Testing.Exe : -
   
       Syntax :--
         Console.WriteLine("New Order  created Successfully:);
    

      Solution

            myProcess.Start();
            myProcess.WaitForExit();
          
           ////Create a streamreader to capture the output of myProcess
              System.IO.StreamReader ischkout = myProcess.StandardOutput;
            if(myProcess.HasExited)
            {
                string output = ischkout.ReadToEnd();
                Response.Write(output);
            }

StandardOut has not been redirected or the process hasn't started yet in C#

          Process myProcess = new Process();   
           string result = string.Empty;
          string FilePath = @"f:\";
          string FilePath = "Notepad.exe";
         
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.FileName = FilePath+ ExeName;
            myProcess.StartInfo.CreateNoWindow = true;         
            myProcess.StartInfo.RedirectStandardOutput = true;
            myProcess.Start();
            myProcess.WaitForExit();
         
            System.IO.StreamReader ischkout = myProcess.StandardOutput;
            if(myProcess.HasExited)
            {
                string output = ischkout.ReadToEnd();
                Response.Write(output);
            }

Try setting standard output redirection before starting the process.

myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.Start();