Archive February 2019

Insert Multiple ROWS in One SQL Query.

INSERT INTO [dbo].[tbl_Page]

Here remamber to put comma at end of value secton expect of last section of value, at the end of last section of value, you have to put semicollon to end the insert statement.

See the image for tested result.

Best way to convert array of object into array of string in C#

I have an array of object in c#

object arrayofobject = new object[] {"Name", "Password", "Address"}

now i want to convert this array of object into array of string so i’ll use Array.CovertAll() method as string array.

string[] arr = Array.ConvertAll((object[])arrayofobject, Convert.ToString);

Full Code Here

object arrayofobject = new object[] {"Name", "Password", "Address"}
string[] arrayofstring = Array.ConvertAll((object[])arrayofobject, Convert.ToString);

now you can get arrayofstring.

Get data of current month only in sql

This is very Simple, Just get month of both of dates which dates you want to compare but both dates should be in date format or you have to cast in date format

get month of any date MONTH() method


it will return only month of this date, just pass date in month method.

if your date in varchar or string format than you should cast in date format

CAST('2019/02/22'AS DATE)

Complete Example Is


On scroll load more data in jquery datatable using Ajax

on scroll in a jquery datatable if you want to add more rows or data than you can use scroll methods and some ajax methods.

var processing;
    $(document).ready(function () {
var currentPageID = 1;
var from = 0;
        var to = 30;
$('.dataTables_scrollBody').on('scroll', function () {
            if (processing)
                return false;
            if ($(this).scrollTop() + $(this).innerHeight() >= ($(this)[0].scrollHeight / 2)) {
                processing = true;
                from = to + 1; // load more 30 records and will append
                to = to + 30;
                FillGrid(from, to, currentPosition); // will call for fill datatable


and here the fillgrid() method to append the 30 rows to datatable, and on sucess data will come as HTML <tr><td></td></tr> view

function FillGrid(from, to, currentPosition) {
            type: "POST",
            url: _rootURL + 'Survey/Grid',
            data: {
                "PageFrom": from,
                "PageTo": to,
            success: function (data) {
                if (!$.trim(data) == '') { 
                    data = data.replace(/^\s*|\s*$/g, '');
                    data = data.replace(/\\r\\n/gm, '');
                    var expr = "</tr>\\s*<tr";
                    var regEx = new RegExp(expr, "gm");
                    var newRows = data.replace(regEx, "</tr><tr");

                    processing = false;
                else {
                    processing = true;

            error: function () {

Get Enum Description According to language culture or resource file in C#

if i have an enum and i want to show the description on view or in dropdown than, than we can change the description according to resource language file.

Full example below:

We have an Enum First

public enum MeetingType
            [Description("Booked Meeting")]
            APPOINTMENTBOOKED = 1,
            [Description("Prescription Bookings")]
            [Description("Prescription Renewal")]

And then we will add these description strings in our resource files.

After Adding strings or key in resource file we have created a extension method for further use.

First import

using System.Resources;

public static string GetDisplayName(this Enum e)
            var rm = new ResourceManager(typeof(DoctorPanel.Resources.Resource));
            var resourceDisplayName = rm.GetString(ExtensionMethod.EnumDescription(e).Replace(" ",string.Empty));

            return string.IsNullOrWhiteSpace(resourceDisplayName) ? string.Format("[[{0}]]", e) : resourceDisplayName;

And use this method where you want to get enum description according to resource or language wise.

var GetString=YourEnum.GetDisplayName();

we used white space remover because, Resource file keys accept without spaces or you can write your enum description without spaces.