Skip to main content

Posts

Showing posts from September, 2012

What is Assembly and what is the different type of assemblies .Net?

“ An assembly may be Public or Private. A public assembly is also called a Shared Assembly.”   The .NET assembly is the standard for components developed with the Microsoft.NET.  Dot NET assemblies may or may not be executable, i.e., they might exist as the executable (.exe) file or dynamic link library (DLL) file. All the .NET assemblies contain the definition of types, versioning information for the type, meta-data, and manifest. The designers of .NET have worked a lot on the component (assembly) resolution. Advantages of Assemblies In the case of DLLs if a DLL has to be shared with some other application, it has to be registered in that particular machine. But, In the case of Asp.net assemblies there is no such type of registration required. Here we just need to do is to copy the assembly and put in the bin directory of the application that is going to use it. If we need to share a particular assembly with any other applications. we can

Difference between Dataset and DataReader

DataSet object DataReader object It is defined with multiple tables. It is a read only and forward only data. It is a disconnected architecture It is comes under connected architecture. Read/Write access Read-only access Bind to multiple controls Bind to a single control Slower access to data Faster access to data Dataset is non persistence. DataReader is persistence.

What is Cursor with examples in SQL Server 2008?

What is cursor? A cursor can be viewed as a pointer to one row in a set of rows. The cursor can only reference one row at a time, but can move to other rows of the result set as needed. To use cursors in SQL procedures, you need to do the following: Declare a cursor that defines a result set. Open the cursor to establish the result set. Fetch the data into local variables as needed from the cursor, one row at a time. Close the cursor when done To work with cursors you must use the following SQL statements: DECLARE CURSOR OPEN CURSOR FETCH ROW By ROW CLOSE CURSOR Example Create the table of Employee CREATE TABLE Employee ( EID INT PRIMARY KEY IDENTITY , ENAME VARCHAR ( 50 ), SALARY DECIMAL ( 10 , 2 ), DEPT VARCHAR ( 50 ) ) INSERT INTO Employee ( ENAME , SALARY , DEPT ) VALUES ( 'ABC' , 2000.00 , 'HR' ) INSERT INTO Employee ( ENAME , SALARY , DEPT ) VALUES (

Check Constraint in SQL-Server

A check constraint is a rule that identifies acceptable column values for data in a row within a SQL Server table. The CHECK constraint ensures that all values in a column satisfy certain conditions. Example We will create an Employee table with Check constraint, Employee Table contain Employee ID, Name and Age. We set Check constraint property on Age column. Age should not be less than 18 Create table of Employee as follows. CREATE TABLE Employee ( EID INT PRIMARY KEY IDENTITY , ENAME VARCHAR ( 100 ), EAGE INT CHECK ( EAGE > 18 ) ) Try to insert the below records INSERT INTO Employee ( ENAME , EAGE ) VALUES ( 'ABC' , 20 ) Check Constraint allowed to insert record in to the Employee table.but when we try to insert below record, it will shows an error Message INSERT INTO Employee ( ENAME , EAGE ) VALUES ( 'PQR' , 15 ) Msg 547, Level 16, State 0, Line 1 The INSERT statement conflicted

Difference between Static Constructor and Private Constructor

Static Constructor Private Constructor The static constructor will only be executed once. The private constructor will be executed each time it is called. The static constructor cannot have parameters. The private Constructor may have parameters A static constructor is called before the first instance is created. So it’s kind of global initialize. Private constructor is called after the instance of the class is created. Inheritance-wise both are same. A class can have only one static constructor A class can have multiple private constructors public static class Class1 {    static Class1()   {    } } public class Class2 {     private Class2()    {    } }