Thursday, 1 December 2016

How Kill a windows Service

C:\Windows\System32>sc queryex  servicesname 

Result get the PID

SERVICE_NAME: servicesname
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 3  STOP_PENDING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 944
        FLAGS     

run the below cmd

C:\Windows\System32>taskkill /PID 944 /F

Friday, 23 September 2016

Get Definition of a view in DB2



select name, cast(text as varchar(10000))
from SYSIBM.SYSVIEWS
where name='CONTACTS_OPENS_VIEW'

Wednesday, 20 July 2016

How to Delete using INNER JOIN with SQL Ser

DELETE FROM WorkRecord2 INNER JOIN Employee ON EmployeeRun=EmployeeNo
Where Company = '1' AND Date = '2013-05-06'

Error - Msg 156, Level 15, State 1, Line 15 Incorrect syntax near the keyword 'INNER'.


You need to specify what table you are deleting from, here is a version with an alias:


DELETE w
FROM WorkRecord2 w
INNER JOIN Employee e
  ON EmployeeRun=EmployeeNo
Where Company = '1' AND Date = '2013-05-06'

Wednesday, 22 June 2016

How to: Write to a Text File C#

 string[] lines = { "First line", "Second line", "Third line" };
        // WriteAllLines creates a file, writes a collection of strings to the file,
        // and then closes the file.  You do NOT need to call Flush() or Close().
        System.IO.File.WriteAllLines(@"C:\Users\Public\TestFolder\WriteLines.txt", lines);


 string text = "A class is the most powerful data type in C#. Like a structure, " +
                       "a class defines the data and behavior of the data type. ";
        // WriteAllText creates a file, writes the specified string to the file,
        // and then closes the file.    You do NOT need to call Flush() or Close().
        System.IO.File.WriteAllText(@"C:\Users\Public\TestFolder\WriteText.txt", text);


Sunday, 5 June 2016

Wednesday, 2 March 2016

Call a javascript function on all Postback





<script type="text/javascript">
 
   $(document).ready(function () {
 var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function (s, e) {
        alert('Postback!'); // write ur Fn here
    });

  });
</script>

Tuesday, 16 February 2016

javascript to capture the browser or tab closed event



/*Refer  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> too*/

var validNavigation = false;

function endSession() {
  // Browser or broswer tab is closed
  // Do here ...
  alert("bye");
}

function wireUpEvents() {
  /*
  * For a list of events that triggers onbeforeunload on IE
  * check http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx
  */
  window.onbeforeunload = function() {
      if (!validNavigation) {
         endSession();
      }
  }

  // Attach the event keypress to exclude the F5 refresh
  $(document).bind('keypress', function(e) {
    if (e.keyCode == 116){
      validNavigation = true;
    }
  });

  // Attach the event click for all links in the page
  $("a").bind("click", function() {
    validNavigation = true;
  });

  // Attach the event submit for all forms in the page
  $("form").bind("submit", function() {
    validNavigation = true;
  });

  // Attach the event click for all inputs in the page
  $("input[type=submit]").bind("click", function() {
    validNavigation = true;
  });
 
}

// Wire up the events as soon as the DOM tree is ready
$(document).ready(function() {
  wireUpEvents();
});