Friday, 29 November 2019

Reverse string using Recursion and loop in c#

Method I. 

       ///// Call- ReverseString('abcdefg');

        //Recursion method; simple, for small strings 
        public string ReverseString(string str)
        {
            if (str.Length <= 1) return str;
            else return ReverseString(str.Substring(1)) + str[0];
        }

     ///// Result- ReverseString - gfedcba


Method II. 

       ///// Call- ReverseString('gfedcba', 0);

       //Recursion method; Need to starting index as 0,  for long strings
        public string ReverseString(string str, int Chrindex)
        {
            char[] chr = str.ToCharArray();
            int len = chr.Length;
            if (Chrindex < len / 2)
            {
                char c = chr[Chrindex];
                chr[Chrindex] = chr[len - Chrindex - 1];
                chr[len - Chrindex - 1] = c;
                Chrindex++;
                return ReverseString(new string(chr), Chrindex);
            }
            else
            {
                return new string(chr);
            }
        }

     ///// Result- ReverseString - gfedcba
Method III.

       ///// Call- ReverseString('abcdefg');

        //Using Another array, need to traverse full array. 
        public string ReverseString(string str)
        {
            char[] chr = str.ToCharArray();
            char[] result = new char[chr.Length];
            for (int i = 0, j = str.Length - 1; i < str.Length; i++, j--)
            {
                result[i] = chr[j];
            }
            return new string(result);
        }

     ///// Result- ReverseString - gfedcba

Method IV.

       ///// Call- ReverseString('abcdefg');

      //Using swap method; need to traverse only half of the array. 
        public string ReverseString(string str)
        {
            char[] chr = str.ToCharArray();
            for (int i = 0, j = str.Length - 1; i < j; i++, j--)
            {
                char c = chr[i];
                chr[i] = chr[j];
                chr[j] = c;
            }
            return new string(chr);
        }

     ///// Result- ReverseString - gfedcba


Thursday, 21 November 2019

Visual Studio always opening a new browser window for ASP.NET MVC application

//////////////// Process

Step 1. Open Visual Studio go to -

       Go to Tools ->Options -> Debugging -> General -> 
          
Unchecked the : Enable JavaScript Debugging for ASP.NET (Chrome and IE) 



Wednesday, 20 November 2019

Get the list of created and / or modified on a operations in sql server

/////////////////////


SELECT * FROM sys.procedures WHERE create_date > '20191110'  ---Particular for the procedure

SELECT * FROM sys.tables WHERE create_date > '20191110'  ------Particularfor the table

SELECT * FROM sys.views WHERE create_date > '20181110'   ------Particular for the View

SELECT * FROM sys.table_types                       -    ----- Particular for the table type

---Get All operated type

SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE CREATED > '20191010' 

---Get All operated type

SELECT * FROM sys.objects WHERE DATEDIFF(D,modify_date, GETDATE()) < 7  



/////////////////////////////////

Wednesday, 6 November 2019

Get List tables in MS Access database

///////// Query



select MSysObjects.name
from MSysObjects
where
   MSysObjects.type In (1,4,6)
   and MSysObjects.name not like '~*'  
   and MSysObjects.name not like 'MSys*'
order by MSysObjects.name



//////////Result/////////

                               

Wednesday, 23 October 2019

Missing Reporting , SSRS or RDLC option in visual studio community 2017

///////////// Setps

Install SSDT

1.      Open Control Panel > Programs > Programs and Features, and select the entry for your version of Microsoft Visual Studio 2017. In our case, it was Microsoft Visual Studio 2017.
2.      Click the "Change" button on the top bar above the program list.
3.      After the splash screen, a window will open. Press the "Modify" button.
4.      Select Windows and Web Development > Microsoft SQL Server Data Tools, and check the box next to it.
5.      Press the "Update" button on the lower-right hand side of the window.

6.      Once the installation is complete, open your version of Visual Studio. After the new .dll files are loaded, Reporting functionality should be re-implemented, and you should be able to access all related forms, controls, and objects.



             
2.     Microsoft RDLC Report Designer for Visual Studio

To install these extensions:
  1. Launch Visual Studio coummunity 2017
  2. Go to Tools Menu
  3. Select Extensions and Updates
  4. In the Extensions and Updates dialog box, select the Online option
  5. Click in the Search Visual Studio Marketplace dialog box, top right hand corner
  6. Type in Report
  7. Press return
  8. Select Microsoft Rdlc Report Design for Visual Studio
  9. Press the Download button
  10. Select Microsoft Reporting Services Project
  11. Press the Download button
  12. Press the Close button
Installation begin when the visual studio is closed

/////////////  Other Steps are given below
















MVC Client side validation using jquery



///////////////////Add Namespace-

      using System.Collections.Generic;

      using System.ComponentModel.DataAnnotations;

//////////////////// Add models with required

   public class Login
    {
        [Required]
        public string UserID { get; set; }
        [Required]
        public string Password { get; set; }

    }


//////////////////// web.config file configuration


<appSettings>
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>


////////////////////  Add J-query Libraries Inside script folder

    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <script src="~/Scripts/jquery.validate.js"></script>

    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script


////////////////////  Call J-query Libraries on page .cshtml

    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <script src="~/Scripts/jquery.validate.js"></script>

    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script


////////////////////  Call J-query Libraries page on top of the page

@{
    Layout = null;
    Html.EnableClientValidation(true);
}







Wednesday, 16 October 2019

DateTime In String Format Using [C#]

//////////////

DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);

String.Format("{0:y yy yyy yyyy}", dt);  // "8 08 008 2008"   year
String.Format("{0:M MM MMM MMMM}", dt);  // "3 03 Mar March"  month
String.Format("{0:d dd ddd dddd}", dt);  // "9 09 Sun Sunday" day
String.Format("{0:h hh H HH}", dt);  // "4 04 16 16"      hour 12/24
String.Format("{0:m mm}", dt);  // "5 05"minute
String.Format("{0:s ss}", dt);  // "7 07"second
String.Format("{0:f ff fff ffff}", dt);  // "1 12 123 1230"   sec.fraction
String.Format("{0:F FF FFF FFFF}", dt);  // "1 12 123 123"    without zeroes
String.Format("{0:t tt}", dt);  // "P PM"A.M. or P.M.
String.Format("{0:z zz zzz}", dt);  // "-6 -06 -06:00"   time zone

// date separator in german culture is "." (so "/" changes to ".")
String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9/3/2008 16:05:07" - english (en-US)
String.Format("{0:d/M/yyyy HH:mm:ss}", dt); // "9.3.2008 16:05:07" - german (de-DE)


// month/day numbers without/with leading zeroes
String.Format("{0:M/d/yyyy}", dt);// "3/9/2008"
String.Format("{0:MM/dd/yyyy}", dt);          // "03/09/2008"

// day/month names
String.Format("{0:ddd, MMM d, yyyy}", dt);    // "Sun, Mar 9, 2008"
String.Format("{0:dddd, MMMM d, yyyy}", dt);  // "Sunday, March 9, 2008"

// two/four digit year
String.Format("{0:MM/dd/yy}", dt);// "03/09/08"

String.Format("{0:MM/dd/yyyy}", dt);          // "03/09/2008"





SortName
DateTimeFormatInfo property
Pattern value (for en-US culture)
t
ShortTimePattern
h:mm tt
d
ShortDatePattern
M/d/yyyy
T
LongTimePattern
h:mm:ss tt
D
LongDatePattern
dddd, MMMM dd, yyyy
f
(combination of D and t)
dddd, MMMM dd, yyyy h:mm tt
F
FullDateTimePattern
dddd, MMMM dd, yyyy h:mm:ss tt
g
(combination of d and t)
M/d/yyyy h:mm tt
G
(combination of d and T)
M/d/yyyy h:mm:ss tt
mM
MonthDayPattern
MMMM dd
yY
YearMonthPattern
MMMM, yyyy
rR
RFC1123Pattern
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' (*)
s
SortableDateTi­mePattern
yyyy'-'MM'-'dd'T'HH':'mm':'ss (*)
u
UniversalSorta­bleDateTimePat­tern
yyyy'-'MM'-'dd HH':'mm':'ss'Z' (*)


(*) = culture independent



//Standard format specifiers in String.Format

String.Format("{0:t}", dt);  // "4:05 PM" ShortTime
String.Format("{0:d}", dt);  // "3/9/2008"ShortDate
String.Format("{0:T}", dt);  // "4:05:07 PM"          LongTime
String.Format("{0:D}", dt);  // "Sunday, March 09, 2008"          LongDate
String.Format("{0:f}", dt);  // "Sunday, March 09, 2008 4:05 PM"  LongDate+ShortTime
String.Format("{0:F}", dt);  // "Sunday, March 09, 2008 4:05:07 PM" FullDateTime
String.Format("{0:g}", dt);  // "3/9/2008 4:05 PM"    ShortDate+ShortTime
String.Format("{0:G}", dt);  // "3/9/2008 4:05:07 PM" ShortDate+LongTime
String.Format("{0:m}", dt);  // "March 09"MonthDay
String.Format("{0:y}", dt);  // "March, 2008"         YearMonth
String.Format("{0:r}", dt);  // "Sun, 09 Mar 2008 16:05:07 GMT"   RFC1123
String.Format("{0:s}", dt);  // "2008-03-09T16:05:07" SortableDateTime
String.Format("{0:u}", dt);  // "2008-03-09 16:05:07Z"UniversalSortableDateTime

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...