Monday, November 22, 2021

Cannot execute script: Insufficient memory to continue the execution of the program

 This error might be happen when you are inserting so many data. Follow these steps

Open cmd.exe as Administrator.

Create Documents directory.

Put your SQL Script file(LCScripty.sql) in the documents folder.

first change the path in cmd prompt by using cd then enter this command and replace with your credential database name and filename

sqlcmd -S <YOUR-SERVER> -U <YOUR-USER> -P <YOUR-PASSWORD> -d <YOUR-DATABASE> -i LCScripty.sql

Tuesday, June 1, 2021

ES6 JavaScript Snippets


/Every Class in javascript is an object
 //Every Function in javascript is an object

//*************************Var/Let/Constant*************** */
//Var ->var variable is accessible in a function if we define any where
//let -> its only accessible in a block that define like in for loop
//const ->similarly to let but its value can't change (its read only)
/*

function sayHello() {
  for (let i = 0; i < 5; i++) {
    console.log(i);
  }
  console.log("************");
  //console.log(i);
}
sayHello();
*/

// const a = 1;
// a = 2;

//*****************************END********************************* */

//******************************Objects******************************** */
/*
const person = {
  name: "Jhon",
  walk() {
    console.log("he can walk");
  },
  talk() {
    console.log("he can talk");
  },
};
person.walk();
const inputfeild = "Sunny";
person["name"] = inputfeild;
console.log(person["name"]);
*/
//*****************************END********************************* */

//******************************This Keyword******************************** */

/*
const person = {
  name: "Jhon",
  walk() {
    console.log(this);
  },
};

//person.walk();
const walk = person.walk();
console.log(walk);
*/
//walk(); // that will not work

//*****************************END********************************* */

//******************************Binding This******************************** */
/*
const person = {
  name: "Jhon",
  walk() {
    console.log(this.name);
  },
};

//person.walk();
const walk = person.walk.bind(person);
walk();
*/

//*****************************END********************************* */

//*************************Arrow Function******************************** */
//if its return line is single so we don't need to user "return Keyword"

/*
const square = (number) => number * number;
console.log(square(5));

const jobs = [
  { id: 1, isActive: true },
  { id: 2, isActive: true },
  { id: 3, isActive: false },
];

// const active_jobs = jobs.filter(function (job) {
//   return job.isActive;
// });

const active_jobs = jobs.filter((job) => job.isActive);
console.log(active_jobs);

*/

//*****************************END********************************* */

//*************************Array.map ******************************** */
// const colors = ["red", "yellow", "green"];
// const items = colors.map((color) => "<li>" + color + "</li>");
// console.log(items);

//*****************************END********************************* */

//*************************Template literals ******************************** */
// const colors = ["red", "yellow", "green"];
// const items = colors.map((color) => `<li>${color}</li>`);
// console.log(items);

//*****************************END********************************* */

//*************************Object Destructing ******************************** */
/*
const address = {
  street: "",
  city: "",
  country: "Pak",
};
//Old technique
// const street = address.street;
// const city = address.city;
// const country = address.country;
// console.log(country);

//const { street, city, country } = address;
const { country: CountryName } = address; // This is How we define Alias "CountryName"
console.log(CountryName);
*/

//*****************************END********************************* */

//*************************Spread Operator ******************************** */
// const first = [1, 2, 3];
// const second = [4, 5, 6];
////Old technique
// const combine = first.concat(second);
// console.log(combine);

//Spread
//const combine = [...first, ...second];
// const combine = [...first, "a", ...second];
// console.log(combine);

//For Obeject
// const first = { name: "Jhon" };
// const second = { job: "Engineer" };
// const combine = { ...first, ...second, Location: "Pak" };
// console.log(combine);

//*****************************END********************************* */

//*************************Classes******************************** */

/*class Person {
  constructor(input_name) {
    this.name = input_name;
    console.log(this.name);
  }
  walk() {
    console.log("He can walk");
  }
}
const obj = new Person("Jhon");
obj.walk();
const obj2 = new Person("Ali");
obj2.walk();

*/

//*****************************END********************************* */

//*************************Inheritance ******************************** */
//If we are adding constructor in child class we should 
use Super keyword in child class that extend
/*

class Person {
  constructor(input_name) {
    this.name = input_name;
    console.log(this.name);
  }
  walk() {
    console.log("He can walk");
  }
}

class Teacher extends Person {
  constructor(Subject, Dept, name) {
    super(name);  
    this.Subject = Subject;
    this.Dept = Dept;
  }
  teach() {
    console.log("He can teach");
  }
}

const teacher = new Teacher("English", "CS", "Ali");
console.log(teacher.Dept);
console.log(teacher.Subject);
console.log(teacher.name);
teacher.teach();
*/
//*****************************END********************************* */

//****************************Module******************************** */
/*
In module we divide the classes in seperate files
By default all the class are private so if we want 
to use it another file you should written "Export Keword"
before the class start
*/

// import { Teacher } from "./teacher";
// const teacher = new Teacher("English", "CS", "Ali");
// console.log(teacher.Dept);
// console.log(teacher.Subject);
// console.log(teacher.name);
// teacher.teach();

//*****************************END********************************* */

//********************Name and Default export ******************************** *
/*
Default export : import Classname from '';
Named export : import {} from ''
*/

//*****************************END********************************* */

//Person Class

export class Person {
  constructor(input_name) {
    this.name = input_name;
    console.log(this.name);
  }
  walk() {
    console.log("He can walk");
  }
}

//Teacher Class

import { Person } from "./person";
export class Teacher extends Person {
  constructor(SubjectDeptname) {
    super(name);
    this.Subject = Subject;
    this.Dept = Dept;
  }
  teach() {
    console.log("He can teach");
  }
}






Monday, May 17, 2021

Regex to allow integer as well as decimal digit(4 decimal)


 ^[1-9]\d*(\.\d{1,4})?$

here you have to keep  number of decimal points to allow.

 <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Amount in decimals is not allowed" ControlToValidate="txtAmount_value" ValidationExpression="^[1-9]\d*(\.\d{1,4})?$" Display="Dynamic"></asp:RegularExpressionValidator>

Tuesday, March 16, 2021

How to remove columns from DataTable in C# and VB.NET

 

Sample C#

1
2
3
DataTable dataTable;
dataTable.Columns.Remove("Columnname");
dataTable.Columns.RemoveAt(index);
dataTable.AcceptChanges();

Sample VB.NET

1
2
3
Dim dataTable As DataTable
dataTable.Columns.Remove("Columnname")
dataTable.Columns.RemoveAt(index)
dataTable.AcceptChanges()

Tuesday, February 9, 2021

Prevent double clicking asp.net button

.Please add below code in your aspx page.If you get Error: 'Sys' is undefined when using this then it is because you need a ScriptManager on the page

<script type="text/javascript" language="javascript">

   Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
   function BeginRequestHandler(sender, args) { var oControl = args.get_postBackElement(); oControl.disabled = true; }

</script>

OR code side

          ' To disable multiple clicks on Save button
                btnTransfer.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnTransfer, Nothing) + ";")
                'To disable multiple clicks on Save button