Skip to main content

Posts

Showing posts from October, 2018

Create /drop Database or Table

{CREATE | DROP} DATABASE – Used to create / alter / delete a database respectively.     Ex: create/drop database TestDB (To created or drop TestDB) {CREATE | ALTER | DROP} TABLE – Used to add / modify / remove table in a database respectively (Ex : create table TableName(ColumnName1 datatype,ColumnName2 datatype,.. as so on),alter table TableName add Column ColumnName3 datatype: drop table TableName (to drop a table)

What is key in Sql Server?

Keys are fields in a table which participate in below activities in RDBMS systems: To create relationships between two tables. To maintain uniqueness in a table. To keep consistent and valid data in database. Might help in fast data retrieval by facilitating indexes on column(s). SQL Server supports various types of keys, which are listed below: Candidate Key Primary Key Unique Key Alternate Key Composite Key Super Key Foreign Key

Different types of Keys in sql server.

Candidate Key Candidate key is a key of a table which can be selected as a primary key of the table. A table can have multiple candidate keys, out of which one can be selected as a primary key. Primary Key Primary key is a candidate key of the table selected to identify each record uniquely in table. Primary key does not allow null value in the column and keeps unique values throughout the column. In SQL Server, by default primary key creates a clustered index on a heap tables (a table which does not have a clustered index is known as a heap table). We can also define a nonclustered primary key on a table by defining the type of index explicitly. A table can have only one primary key and primary key can be defined in SQL Server using below SQL statements: CRETE TABLE statement (at the time of table creation) – In this case, system defines the name of primary key ALTER TABLE statement (using a primary key constraint) – User defines the name of the primary key Uni...

Export html table to csv using javascript

<table>     <tr><th>Name</th><th>Age</th><th>Country</th></tr>     <tr><td>MANOJ</td><td>26</td><td>INDIA</td></tr>     <tr><td>KRISHAN</td><td>19</td><td>INDIA</td></tr>     <tr><td>SUSHEEL</td><td>32</td><td>INDIA</td></tr> </table> <button onclick="Export_CSV ()">Export HTML table to CSV file</button> function download_csv(csv, filename) {     var csvFile;     var downloadLink;     csvFile = new Blob([csv], {type: "text/csv"});     downloadLink = document.createElement("a");     downloadLink.download = filename;     downloadLink.href = window.URL.createObjectURL(csvFile);     downloadLink.style.d...

Sql CharIndex Function

The CHARINDEX  function returns the starting position of the specified expression in a character string. Example: Search for "t" in string "DotNetReceipe", and return position: SELECT CHARINDEX( 't' , 'DotNetReceipe' ) AS Position;

TYPE CASTING in C#

Type casting is a process in which you will convert one type of data into another type of data Implicit Type Casting Explicit Type Casting Implicit Type Casting Implicit type casting is the casting which is done by your CLR of compiler. In this type of casting it will itself convert one type into another type . But the only condition is that the conversion must be compatible. Example Int x = 5; Float y = 6f; y=x; Explicit Type Casting Explicit is the process in which we manually convert the one type of data into another type of data . But there is a chance of data loss in type of explicit type of casting. Apart from this the data type must be compatible.

Set dropdown value by text in jquery

 var purpose = 'SomeText';                         $("#ddlPurpose option").each(function () {                             if ($(this).text() == purpose) {                                 $(this).attr('selected', 'selected');                             }                         });

STATIC METHOD in C#

Static methods are those methods which are known as a class level method. We call the static method with the name of class. Example Public Class1 { Public static int sum (int x, int y) { Return x+y; } } Calling of Static Method: Response. Write (Class1.sum (45, 55));

STATIC VARIABLE in C#

Static variables are those variables which persist their value throughout your project. Static veriable also known as class variable.Although there are the class variables so when the class load in the memory the static memory will be allocated. Example Public static int c;

COLLECTION in C#

When we need to store any kind of data then we use collection and can hold all data at run time.  The namespace which collection use is system collection. The only drawback of collection is that when we retrieve the data from collection we have to implement type casting.

2-d (Dimensional) ARRAY in C#

Two dimensional arrays are those arrays which are used to maintain data in the form of row and column. It stored in tabular format. Declaration of 2D array Int [,] marks = new int [3, 4]; For (int i = 0; i<3; i++) { For (int j=0; j<4; j++) { Marks [I,j] = 34; } }

What is Array in C#

Array is a collection of similar data types. In array we access the value using index. Declaration of array Int [ ] marks = new int [5]; Assigning value to the array Marks [0] = 90; Marks[1] = 80; Int [ ] marks = new int [ 5 ] { 2, 3,4,5,6 } Int [ ] marks = { 2, 3, 4,5, 6,7,8} Retrieving value from Array int Sum = 0; For (int i=0; i<= marks. Length; i++) { Sum = Sum + marks [i]; } Response. Write (sum);

What is interface in C#

Interface are use to create the structure of any project. In interface all methods are by default Public and not define access specifies. In interface we can only declare method & we implement this interface into the class and give definition to all method. We create interface using “interface” Keyword. Example Public interface IClass { Int sum (int x, int y) Int mul (int x, int y) }

What is sealed class in C#

Sealed classes are those classes which cannot be inherited . It means we cannot inherit the sealed class the only way to create object of that class and then use it. Below is a sample of sealed class // Sealed class sealed class SampleSealedClass {     public int Add(int x, int y)     {         return x + y;     } }

Inheritance in c#

It is the process in which we can reuse our code and we can also extend the functionality of class in to the other class. Public class 2005 { Public string keypress () { Return “Key press of car”; } } Public class 2008:2005 { Public string music system() Return  “ music system”; } { Class 2008 c = new class 2008() c.keyPress (); c.musicSystem (); }

Method/Function Overloading in C#

Method overloading is a process in which we create the method with the same name with different parameter. There are three types of method overloading in c# which is as follows. Number of Parameter - in number of parameter we change the count of parameter to the method of same name. For example Public int sum(int x, int y) { Return x+y; } Public  int sum(int x, int y, int z) {  Return x=y+z; } Data Type of Parameter- we will simply change the data type of parameter passing to the method of same name. public int sum(int x , int y) {  Return x+y; } Public string sum(string x, string y) { Return x+y; } Sequence of Parameter- In the third rule of method overloading we can change the sequence of parameter of same method. Example public string sum(string x, int y) { Return x+y; } Note - Return type does not bother in method overloading.

Difference between Primary Key and Unique Key

The difference between primary key and unique key is given bellow: Primary Key A table can have only one primary key A primary key have an implicit NOT NULL constraint It cannot contain NULL values Unique Key A table can have more than one unique key A unique key have not  implicit NOT NULL constraint It may or may not contain NULL values

What is Primary Key?

A Primary key is a column or a set of columns that can uniquely identify a row in a table. A table can have at most one primary key. A primary key have an implicit NOT NULL constraint. So, a column that is defined as the primary key cannot have NULL values in it.

What is Unique Key?

A unique key is a column or a set of columns that can uniquely identify a row in a table. So, a unique key is constraint such that no two values of it are equal. Unique key allows only a single NULL value in that column. Depending on the design of a database, a table may have more than one unique key.

Difference between SQL Function and Stored Procedure

The main difference between functions and stored procedures  are given bellow: Function(User Defined) It returns only one value We can’t use transaction in function Only have input parameter We can’t called SP from function We can’t use exception handling using Try-Catch block in function We can use function in select/where/having statement Stored Procedure (Store Procedure) It returns zero, single or multiple values We can use transaction in SP Can have input/output parameter We can called function from SP We can use exception handling using Try-Catch block in SP We can’t use SP in select/where/having statement

What is Stored Procedure

Stored Procedure is a set of SQL statement which is written in database server or database. It can handle complex operation according to input. Its input is called parameter. Any Stored Procedure may have multiple parameters or not. If we write code in Stored Procedure rather than client end it is faster. Because  Stored Procedure stay & run inside database server.

What is constructor

Constructor is a special type of method which is use to initialized your class member variable . Below is a Sample code for constructor :- public class SampleClass {     public SampleClass()     {         //         // TODO: Add constructor logic here         //     } }

What is Class in c#

Class is a user defined data type . It is the most powerful feature. Classes are the way to realize what your entity is. Below is a SampleClass :- /// <summary> /// Summary description for SampleClass /// </summary> public class SampleClass {     public SampleClass()     {         //         // TODO: Add constructor logic here         //     } }

Why do we use jQuery?

Due to following advantages we use jQuery. Easy to use and learn. Easily expandable. Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+) Easy to use for DOM manipulation and traversal. AJAX Capabilities. Methods for changing or applying CSS, creating animations. Event detection and handling. Tons of plug-ins for all kind of needs.

What is jQuery?

jQuery is fast, lightweight and feature-rich client side JavaScript Library/Framework which helps in to traverse HTML DOM, make animations, add Ajax interaction, manipulate the page content, change the style and provide cool UI effect. It is one of the most popular client side library and as per a survey it runs on every second website.