Friday 28 July 2017

SQL statement to get column from table type table

//Sql Query


select c.name,t.name from sys.columns asJOIN sys.types AS t ON c.user_type_id=t.user_type_id

WHERE c.object_id IN ( SELECT type_table_object_id FROM sys.table_types WHERE name =  'TableType table name') order by c.column_id

Thursday 27 July 2017

Sql server paging

// SQL server

Declare @PageNo int=5,@pageSize int=5

select top (@pageSize) * from(select ROW_NUMBER() OVER(ORDER BY hhguid ASC) as line, * from tblhh where createdby=94)mm

where line > (@PageNo - 1) * @pageSize

Monday 24 July 2017

Check Uncheck all using Jqury with Parent and Child case

// Jquery function

function CheckUncheck_AllCheckBoxes(chk, CheckParentID) {
    $('[id*=' + CheckParentID + ']').find("input:checkbox").each(function () {
        if (this != chk) {
            this.checked = chk.checked;
        }
    });
    return false;

}




// Html or Asp.net

<asp:CheckBox runat="server" ID="Chk_allFrequency"  onclick="CheckUncheck_AllCheckBoxes(this,'Parent ID static');"

 CssClass="pull-left" Text="Frequency" Checked="true" />



                                      

Monday 17 July 2017

Write exception log in asp.net c#

// Method

private static String ErrorlineNo, Errormsg, extype, exurl, hostIp, ErrorLocation, HostAdd;


public static void Write_Logs(Exception ex)
    {
        var line = Environment.NewLine + Environment.NewLine;

        ErrorlineNo = ex.StackTrace.Substring(ex.StackTrace.Length - 7, 7);
        Errormsg = ex.GetType().Name.ToString();
        extype = ex.GetType().ToString();
        exurl = context.Current.Request.Url.ToString();
        ErrorLocation = ex.Message.ToString();

        try
        {
            string filepath = context.Current.Server.MapPath("~/Ex_Log/");  //Text File Path

            if (!Directory.Exists(filepath))
            {
                Directory.CreateDirectory(filepath);
            }
            filepath = filepath + DateTime.Today.ToString("dd-MM-yy") + ".txt";   //Text File Name
            if (!File.Exists(filepath))
            {
                File.Create(filepath).Dispose();
            }
            using (StreamWriter sw = File.AppendText(filepath))
            {
                sw.WriteLine(line);
                string error = "Date:" + " " + DateTime.Now.ToString() + "," + "LineNo :" + " " + ErrorlineNo + "," + "Message:" + " " + Errormsg + "," + "ExceptionType:" + " " + extype + "," + "Location :" + " " + ErrorLocation + "," + "PageUrl:" + " " + exurl + "," + "HostIP:" + " " + hostIp;
                sw.Flush();
                sw.Close();

            }

        }
        catch (Exception e)
        {
            e.ToString();

        }
    }



//Call


    protected void btn_backCatalogue_Click(object sender, EventArgs e)
    {
        try
        {
        }
        catch (Exception ex)
        {
            Write_Logs(ex);
        }
    }

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...