Monday, 12 December 2016

How to Find Maximum & Minimum Element in the Array Program in C

  1. #include<stdio.h>  
  2. # include<conio.h>  
  3. void main()  
  4. {  
  5. int a[100],i,n,max,min;  
  6. clrscr();  
  7. printf("How many elements in the array : ");  
  8. scanf("%d",&n);  
  9. printf("Enter the elements : \n");  
  10.   for(i=0;i<=n-1;i++)  
  11.     {  
  12.      scanf("%d",&a[i]);  
  13.     }  
  14. max = a[0];  
  15. min = a[0];  
  16.   for(i=1;i<=n-1;i++)  
  17.    {  
  18.     if(max<a[i])  
  19.     max = a[i];  
  20.    if(min>a[i])  
  21.    min = a[i];  
  22.   }  
  23. printf("maximum element in the array is :%d\n ",max);  
  24. printf("minimum element in the array is : %d\n",min);  
  25. getch();  
  26. }  

Get Web Browser Name In C#

  1. public string GetWebBrowserName()  
  2.     {  
  3.         string WebBrowserName = string.Empty;  
  4.         try  
  5.         {  
  6.             WebBrowserName = HttpContext.Current.Request.Browser.Browser;  
  7.         }  
  8.         catch (Exception ex)  
  9.         {  
  10.             throw new Exception(ex.Message);  
  11.         }  
  12.         return WebBrowserName;  
  13.     }  

DOS Command (CMS) Create Folder Current Datetime and Move Files Shared Folder

  1. @echo off    
  2. set hh=%time:~-11,2%    
  3. set /a hh=%hh%+100    
  4. set hh=%hh:~1%    
  5. set dateseed=%date:~10,4%%date:~4,2%%date:~7,2%_%hh%    
  6.     
  7. %time:~3,2%%time:~6,2%    
  8.     
  9. if not exist "\\140.175.165.10\Sharing\Databasebackup\    
  10.     
  11. %dateseed%" mkdir "\\140.175.165.10\Sharing    
  12.     
  13. \Databasebackup\%dateseed%"    
  14.     
  15. copy D:\HELLO "\\140.175.165.10\Sharing\Databasebackup\    
  16.     
  17. %dateseed%"   

Friday, 9 December 2016

How to Use While LOOP in SQL

  1. DECLARE @TOTALV BIGINT  
  2. DECLARE @InitialValue BIGINT  
  3. SET @InitialValue=1  
  4. SET @TOTALV=12  
  5. WHILE (@InitialValue<=@TOTALV)  
  6. BEGIN  
  7. print @InitialValue  
  8. SET @InitialValue=@InitialValue+1  
  9. END  

Tuesday, 6 December 2016

SQL Function Get Total Time in HH:MM:SS

  1. CREATE FUNCTION [dbo].TotalTime  
  2. (                      
  3.   @StartTime DATETIME,                      
  4.   @EndTime DATETIME  
  5. )                      
  6. RETURNS Varchar(10)                      
  7. AS                      
  8. begin     
  9. DECLARE @D VARCHAR(400)='31784'  
  10. Declare @outTime Varchar(10);      
  11. SELECT @D = DATEDIFF(SECOND,@StartTime,@EndTime)   
  12.   
  13.   
  14.  SELECT @outTime =CONVERT(VARCHAR(5), @D/60/60)  
  15.   + ':' + RIGHT('0' + CONVERT(VARCHAR(2), @D/60%60), 2)  
  16.   + ':' + RIGHT('0' + CONVERT(VARCHAR(2), @D % 60), 2)  
  17.   
  18.                      
  19.  RETURN  @outTime                      
  20. END    
  21. GO  
  22.   
  23.   
  24.   
  25.   
  26.    SELECT dbo.TotalTime('2016-08-10 10:36:01.000','2016-08-10 19:25:45.000'

How to remove empty lines in text In Visual

Visual Studio has ability to delete empty lines in replace operation using regular expressions.
  • Click Ctrl-H (quick replace)
  • Tick "Use Regular Expressions"
  • In Find specify ^$\n
  • In Replace box delete everything.
  • Click "Replace All"
All empty lines will be deleted.
Regular expression for empty line consist of
Beginning of line ^
End of line $
Line break \n

SQL Group With Group Total

  1. SELECT isnull(WO_status,0) as WO_status,          
  2. (case  when MwO.WO_status=1 then 'Open' when MwO.WO_status=2 then 'Close' when MWO.WO_status=3 Then  'Short Close'          
  3. when MwO.WO_status=4 then 'Cancel'          
  4.  else 'Total' endas statusR,          
  5. count(*) as countValue                            
  6. FROM   M_WorkOrder MwO                         
  7.  inner join    M_WorkorderDetails MwOd  on MwO.WOID=MwOd.WOD_WOID                                                        
  8. INNER join BILL_KEYWORD BK  on BK.id=MwOd.WOD_KEYID                                                        
  9. INNER join billing_from bf      on bf.id=MwO.WO_CID                               
  10.  where  (MwOd.WOD_CUserID=15 or 15 =0 )              
  11.  group by WO_status  WITH ROLLUP

Upload valid file in C#

    protected bool CheckFileExtandLength(HttpPostedFile HtmlDocFile)     {         try         {             Dictionary<string, byte[]...