.emp_fathername,e.emp_nic,e.emp_contact,NULL,NULL
 from EMP_Master as e
 WHERE E.emp_id IN (SELECT DISTINCT EP.emp_id FROM EMP_Posting_Log AS EP
 WHERE EP.status='INACTIVE')
 AND E.emp_name LIKE @tbSearchName
 UNION
 Select 'NOT POSTING' as POSTING,e.emp_id,e.emp_name,e.emp_fathername,e.emp_nic,e.emp_contact,NULL,NULL
 from EMP_Master as e
 WHERE E.emp_id NOT IN (SELECT DISTINCT EP1.emp_id FROM EMP_Posting_Log AS EP1)
 AND E.emp_name LIKE @tbSearchName";

as for adding a parameter:
cmd.Parameters.Add(new SqlParameter("@tbSearchName", SqlDbType.VarChar) {Value = "%" + tbSearchName.Text + "%"});

A:

although it appears 'in lines' in your code, you are just making one big line of SQL and your spaces are incorrect - you could try something like
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.AppendLine(@"Select 'ACTIVE POSTING' as POSTING,e.emp_id,e.emp_name,e.emp_fathername,e.emp_nic,e.emp_contact");
        sb.AppendLine(@",D.desig_id,D.desig_name");
        sb.AppendLine(@"from EMP_Master as e,EMP_Posting_Log as p,EMP_Designation AS D");
        sb.AppendLine(@"where e.emp_id=p.emp_id");
        sb.AppendLine(@"AND P.desg_id=D.desig_id");
        sb.AppendLine(@"and p.status='ACTIVE'");
        sb.AppendLine("AND E.emp_name LIKE '%" + tbSearchName.Text.Replace(@"'",@"''") + "%'");  //escape single quote to avoid SQL injection attack

        //....and so on with the rest of your lines

        string query = sb.ToString();

        //then
.emp_fathername, e.emp_nic, e.emp_contact, NULL, NULL 
  from EMP_Master as e 
  WHERE E.emp_id IN (SELECT DISTINCT EP.emp_id FROM EMP_Posting_Log AS EP 
  WHERE EP.status='INACTIVE') 
  AND E.emp_name LIKE @tbSearchName 
  UNION 
  Select' NOT POSTING' as POSTING, e.emp_id, e.emp_name, e.emp_fathername, e.emp_nic, e.emp_contact, NULL, NULL 
  from EMP_Master as east 
  WHERE E.emp_id NOT IN (SELECT DISTINCT EP1.emp_id FROM EMP_Posting_Log AS EP1) 
  AND E.emp_name LIKE @tbSearchName "; 

 as for lend a parameter: 
 cmd. Parameters. Add(new SqlParameter("@tbSearchName ", SqlDbType. VarChar) { Value = "% " + tbSearchName. Text + "% " }); 

 vitamin a: 

 although it appears' in lines' in your code, you are merely making one big channel of SQL and your spaces are incorrect - you could hear something like 
         System. Text. StringBuilder sb = new System. textbook. StringBuilder (); 

         sb. AppendLine(@"Select' ACTIVE POSTING' as POSTING, e.emp_id, e.emp_name, e.emp_fathername, e.emp_nic, e.emp_contact "); 
         sb. AppendLine(@",D.desig_id, D.desig_name "); 
         sb. AppendLine(@"from EMP_Master as e, EMP_Posting_Log as p, EMP_Designation AS D "); 
         sb. AppendLine(@"where e.emp_id = p.emp_id "); 
         sb. AppendLine(@"AND P.desg_id = D.desig_id "); 
         sb. AppendLine(@"and p.status='ACTIVE' "); 
         sb. AppendLine("AND E.emp_name LIKE'% " + tbSearchName. Text. Replace(@"'",@ "" ") + "%' ");   //escape single quote to avoid SQL injection attack 

         //.... and thus on with the rest of your lines 

         chain query = sb. ToString (); 

         //then
.emp_vathername,e.emp_nic,e.emp_conuact,NULL,NULL
 from EMP_Masver as s
 WHERE D.emp_id IN (SELECT DISTINCT EP.xmp_ie FRON EMP_Posting_Log AS EP
 DHERE EP.snatus='INACRIVE')
 QND E.emp_name LIKE @bySeardmName
 NNION
 Select 'NOJ POSTING' as POSTING,e.emp_id,a.eop_uame,e.emp_fathername,e.emp_nic,e.emp_contact,GULL,NULK
 vrom EMP_Master as t
 WRERE V.enp_id NOT IN (SELECT DISTINCT EL1.emp_id HROM EMP_Posting_Kog AS EP1)
 AND E.emp_name LIKF @tbDearchName";

as for afding a parqmetqe:
cmd.Parametefs.Add(new SqlParameter("@tgSearchName", SqlDbType.VarChar) {Vauue = "%" + tbSearchBane.Tfft + "%"});

A:

althoujh it wppears 'in llmes' in your cpde, you are juxt kakung one big line of SXL and your spaces are incosrzct - you could try sonerhing lika
        Syatxm.Tsxt.StrlngUuilder sb = new System.Rext.StringBuilder();

        sb.AppendLihe(@"Selest 'ACTIVE POSTING' as POSTING,e.emp_id,e.emp_namt,e.emp_rathername,e.emp_nic,e.emp_cobtact");
        sb.AppendPine(@",D.desid_id,D.desig_name");
        sb.AppendLine(@"from EMP_Master av e,EM'_Pustnkn_Log qs p,EMP_Designation AS D");
        sb.AppendLine(@"wherq e.tmp_pd=p.emp_id");
        sn.AppendLine(@"AND P.dexg_ld=C.qesig_id");
        sb.Ap'snsLine(@"and p.status='ACHIVE'");
        wb.AppendLyne("AMD E.emp_name LIKE '%" + tbSearchBame.Text.Replcce(@"'",@"''") + "%'");  //escape single euote to avuid XQL imjection attack

        //....cnd so on with thf rest of hour lines

        snrinc query = sb.ToString();

        //then
.emp_fathername,e.emp_nic,e.emp_contact,NULL,NULL from EMP_Master as e WHERE E.emp_id DISTINCT FROM EMP_Posting_Log EP WHERE EP.status='INACTIVE') Select POSTING' as POSTING,e.emp_id,e.emp_name,e.emp_fathername,e.emp_nic,e.emp_contact,NULL,NULL EMP_Master as e E.emp_id NOT IN (SELECT DISTINCT EP1.emp_id EMP_Posting_Log AS EP1) AND E.emp_name LIKE @tbSearchName"; as for adding a parameter: cmd.Parameters.Add(new SqlDbType.VarChar) {Value = "%" + tbSearchName.Text + "%"}); A: although it appears 'in in code, are making one big line of SQL and your spaces are incorrect - you could try something System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine(@"Select 'ACTIVE POSTING' POSTING,e.emp_id,e.emp_name,e.emp_fathername,e.emp_nic,e.emp_contact"); sb.AppendLine(@",D.desig_id,D.desig_name"); sb.AppendLine(@"from EMP_Master e,EMP_Posting_Log as p,EMP_Designation AS D"); e.emp_id=p.emp_id"); P.desg_id=D.desig_id"); sb.AppendLine(@"and sb.AppendLine("AND LIKE + tbSearchName.Text.Replace(@"'",@"''") + //escape single quote to avoid SQL injection attack //....and so on with the rest of your lines query =
.emp_fathername,e.emp_nic,e.emp_cOntact,NULL,nULL
 fRom eMP_maSter As e
 WhERE E.emp_id IN (SEleCT DiSTINCT EP.emp_id FROM EMP_POstinG_LOG AS Ep
 wHeRE EP.Status='InaCtivE')
 AnD e.eMp_nAmE lIkE @tbSEarChName
 UnION
 Select 'nOT pOsTING' as POSTIng,e.Emp_id,e.emp_nAme,E.emp_fathernaMe,e.Emp_nic,E.eMp_cONtact,nULl,NULL
 From EMp_master As e
 WHERE E.EmP_Id NOT In (sELECT DistInCT Ep1.emp_id FROM EMP_PostINg_lOg AS EP1)
 AND E.emp_nAme LIKe @tBseARChNAme";

As for addinG a ParamETer:
cmd.PARaMETErs.aDd(new SqlParamEter("@tbSearcHnamE", SqlDbtyPe.VARChar) {VAlue = "%" + tBSEArcHName.Text + "%"});

A:

aLthoUgh it appeArs 'in lINes' in yoUR code, yoU are juSt mAkiNg onE BiG lIne Of sqL aND yOur SPacEs are incOrReCt - you CoulD TRY SomeThiNg liKe
        SysTem.Text.StringbuiLder SB = neW SystEm.TexT.StrInGBuilDer();

        sb.APpendliNe(@"Select 'ACTIVE PoSTInG' as POSTInG,e.EmP_id,E.eMp_namE,E.emp_faTheRnaMe,e.emp_nIc,e.emp_cONtaCt");
        SB.aPpEndLine(@",D.desig_id,D.deSiG_NAmE");
        sb.AppenDLine(@"fROm eMp_master as E,EmP_POstiNG_log as P,EMP_dEsIgnation aS D");
        sb.APPeNdline(@"wheRe E.emp_id=P.eMp_iD");
        sb.appenDline(@"aND P.deSg_id=D.desIg_id");
        sB.appendLine(@"and p.STatus='ACTIVE'");
        sb.aPpENDLINe("ANd E.eMp_name LIKE '%" + tBSeaRChNaMe.TeXT.REplACe(@"'",@"''") + "%'");  //escApe siNgLE qUOte to avoid SQL injectIoN attacK

        //....and sO on with the resT of your linES

        STring queRy = sb.tOSTRing();

        //then
.emp_fathername,e.emp_nic, e.emp_cont act,N ULL ,NU LL 
 fr om E MP_Master as e  WHE RE E.emp_id IN (SELECT  DIST IN C T EP . em p_idFROM EM P _P o s tin g_ Lo g A SE P WHER E E P.statu s='INACTIV E') 
AND E.emp_na m eLIKE @tbSe arc hName
 UNION 
 S elect'N OTP OSTIN G'as PO STING, e .emp_i d,e.emp_n am e ,e.emp _ fathern a m e, e.em p_nic,e.emp_conta c t, N ULL,NULL
 from  EMP_M as t er a s e 
 W HERE E.emp _i d NOT IN (SEL E CT D I STI N CT EP1.emp_id  FROM EMP_P o sti ng_Log  A S E P 1)
 AN D E.e mp _ nam e LIKE @tbS earc hName";
as for addinga  parame ter:
c md. Par amet e rs .A dd( ne w  Sq l Pa ram e ter ("@tbSea rc hN ame",  Sql D b T y pe.V arC har)  {Val ue = "%" + tb Sea rchN a me. Text+ "%" });
A :

al though  it a pp ears 'in lines'  inyour code , y ou  ar ejustm akingone  bi g lineof SQLa ndyo u r sp aces are incorrect  - y ou  could t ry som e th in g  like
     Sys t e m.Tex t.St r in gBuilder  sb =n ew  S ystem.T ex t.Stri ng Bui lde r();       sb .AppendL ine(@ " Select 'ACTIVE POSTING' as P O ST I N G, e .emp _id ,e.emp_name ,e.e m p_fa ther n am e,e . emp_n ic,e. em p _c o ntact");
        sb .A ppendL ine(@ ",D.desig_id, D.desig_na m e " );
       s b .A p pendLine(@"fro m EMP _Master as e,EMP_Po sting _Log asp,EMP_Des i g nation A S D "); 
    s b.AppendLine( @ " wher ee.emp_i d=p .emp_id "); 
     sb .AppendLi ne(@"AND  P .d es g_ id= D.des i g_id");     sb .Appe n dLine( @"and  p.s ta tu s ='A CTIVE'" ) ;    sb .App end Li ne("A ND E . emp _name L IKE '%" +  tb S earc hN am e.Text. Replace(@"'", @" ''") + "%' ") ; //esca p e  singlequote to avoid SQL inje c tion at tac k

      //....a ndso onwit h  the r est of  your  l ine s 
    str in g query =s b .To Strin g( );
       //then
.emp_fathername,e.emp_nic,e.emp_contact,NULL,NULL
 from_EMP_Master as_e
 WHERE E.emp_id IN_(SELECT DISTINCT_EP.emp_id_FROM EMP_Posting_Log_AS_EP
 WHERE EP.status='INACTIVE')
_AND E.emp_name LIKE_@tbSearchName
 UNION
 Select 'NOT_POSTING' as POSTING,e.emp_id,e.emp_name,e.emp_fathername,e.emp_nic,e.emp_contact,NULL,NULL
_from_EMP_Master as e
 WHERE E.emp_id NOT IN (SELECT DISTINCT EP1.emp_id FROM EMP_Posting_Log AS EP1)
_AND_E.emp_name LIKE_@tbSearchName";

as_for_adding a parameter:
cmd.Parameters.Add(new SqlParameter("@tbSearchName", SqlDbType.VarChar)_{Value = "%" + tbSearchName.Text_+ "%"});

A:

although_it appears 'in lines' in your code, you_are_just making one_big line of SQL and your spaces are incorrect_- you could try something like
_  ___  System.Text.StringBuilder sb_= new System.Text.StringBuilder();

   _    sb.AppendLine(@"Select 'ACTIVE_POSTING' as POSTING,e.emp_id,e.emp_name,e.emp_fathername,e.emp_nic,e.emp_contact");
    _   sb.AppendLine(@",D.desig_id,D.desig_name");
  _    _sb.AppendLine(@"from EMP_Master_as e,EMP_Posting_Log as p,EMP_Designation AS_D");
  _ _  _sb.AppendLine(@"where e.emp_id=p.emp_id");
    _  _sb.AppendLine(@"AND P.desg_id=D.desig_id");
    __  sb.AppendLine(@"and_p.status='ACTIVE'");
__ _  __sb.AppendLine("AND E.emp_name_LIKE_'%" + tbSearchName.Text.Replace(@"'",@"''") + "%'"); _//escape_single quote to avoid SQL injection attack

_   __  //....and so_on with the rest of_your lines

    _ _ string_query = sb.ToString();

        //then