Share Blog

Wednesday, August 19, 2015

What is Class, Constructor, Generics, Namespaces , Object, Static?

Class: A program is an abstract machine. As it executes, its parts are in movement, in constant motion, moving towards a result.

Constructor: We often need to have different ways of instantiating a class. We might use the class in many places. With overloading, we can add many entry points for creating the class.

Generics :A generic class is compiled for a certain parameter type, one specified in angle brackets. Generics (like Dictionary) are powerful. They are often faster than alternatives.

Namespaces : Namespaces are an organizational feature. Often, programs will have namespaces containing their classes. This changes the syntax. It alters how we must identify a target class.

Object: Every class is derived from the ultimate base class—object. Because of this, every variable can be cast to an object reference. We treat any variable as one type.


Static: The word "static" refers to a position that is unchanging, fixed. A static class cannot be instantiated. Its position in memory is therefore fixed in one place.

Wednesday, August 12, 2015

Binding all countries to dropdownlist in Asp.net Using System.Globalization in C#


To get all countries in asp.net first open your aspx page and write the following code


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Bind_Country.aspx.cs" Inherits="Bind_Country" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Binding all countries to dropdownlist in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <b>Select Country:</b>
        <asp:DropDownList ID="ddlcountry" runat="server">
        </asp:DropDownList>
    </div>
    </form>
</body>
</html>


Now add following namespaces in code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;


After completion of Adding namespaces you need to write the code like as shown below


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;

public partial class Bind_Country : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<string> objcountries = new List<string>();
            CultureInfo[] objculture =CultureInfo.GetCultures(CultureTypes.SpecificCultures);
            foreach (CultureInfo getculture in objculture)
            {
                RegionInfo objregion = new RegionInfo(getculture.LCID);
                if (!(objcountries.Contains(objregion.EnglishName)))
                {
                    objcountries.Add(objregion.EnglishName);
                }
            }
            objcountries.Sort();
            ddlcountry.DataSource = objcountries;
            ddlcountry.DataBind();
        }


    }
}


Result




Saturday, August 08, 2015

SQL Server Interview Question And Anser For Fresher And Experience Part 4

1.
Define Unique Key?

§  Unique key is a one or more column that must be unique for each row of the table.
§  It is similar to primary key. Primary key column will not accept a null. Whereas the unique key column will accept a null values.

2.
Define Joins?

A Join combines columns and data from two or more tables (and in rare cases, of one table with itself).

3.
Define Indexes?

Index is a general term for an Oracle/SQL features used to primarily to speed execution and imposes uniqueness upon certain data.
The most important of an index is to ensure uniqueness of rows and help in speedy retrieval of data.

4.
What are the difference between primary keys and foreign keys?

The primary key is the columns used to uniquely identify each row of a table.A table can have only one primary key.
Foreign keys are both a method of ensuring data integrity and a manifestation of the relationship between tables.

5.
Define Clusters?

Clustering is a method of storing tables that are intimately related and often joined together into the same area on disk.
A cluster contains one or more tables, which have one or more column in common among them.

6.
What are some of the objects held in a database?

§  Tables
§  Columns
§  Data types
§  Stored procedures
§  Triggers
§  Rules
§  Keys
§  Constraints
§  Defaults
§  Indexes

7.
What is the difference between the HAVING clause and the WHERE clause?

SQL Server Express applies the HAVING clause after it summarizes the data, whereas it applies the WHERE clause before it summarizes the data.

8.
Name the three types of user-defined functions?

§  Scalar
§  Inline table–valued
§  Multi-statement table–valued.

9.
What is an identity column?

Identity columns provide an autoincrementing value for a table.

10.
What component installs the OLEDB and ODBC drivers?

The MDACs (Microsoft Data Access Components).

11.
What is denormalization and when would you go for it?

Denormalization is the process of attempting to optimize the performance of a database by adding redundant data or by grouping data.Denormalization is the reverse process of normalization.

12.
What keyword do you use to assign a value to a variable?

The SELECT keyword.

13.
What are the advantages of SQL Server 2005 Express?

§  SQL Server 2005 Express is free and is easy to use.
§  It provides the same protection and information management provided by more sophisticated versions of SQL Server.
§  It is easy to install, provides rich database functionality, and sports deep integration with Visual Studio 2005.

14.
What function finds the difference between two dates?

The DATEDIFF function.

15.
What does the RETURN statement do?

The RETURN statement unconditionally exits a stored procedure without executing any other statements.

16.
What does NULL mean?

The value NULL means UNKNOWN; it does not mean (empty string). Assuming ANSI_NULLS are on in your SQL Server database, which they are by default, any comparison to the value NULL will yield the value NULL.

17.
What are the Different Types of Normalization?

§  First Normal Form
§  Second Normal Form
§  Third Normal Form
§  Boyce’s Normal Form
§  Fourth Normal Form
§  Fifth Normal Form

18.
What are Page Splits?

Pages are contained in extent. Every extent will have around eight data pages. But all the eight data pages are not created at once; they are created depending on data demand. So when a page becomes full it creates a new page, this process is called as “Page Split”.

19.
What is an Identity?

Identity is a column that automatically generates numeric values.

20.
What is a covered index?

A covered index is a non clustered index that contains all the columns in a query.

21.
What is the difference between SET and SELECT?

Both SET and SELECT can be used to assign values to variables. It is recommended that SET @local_variable be used for variable assignment rather than SELECT @local_variable.

Examples
declare @i int
set @i=1
This is used to assign constant values.

select @i=max(column_name)from table_name
for ex.
select @i=max(emp_id) from table_emp.

22.
What is the difference between char , varchar and nvarchar?

char(n)Fixed length non unicode character data with length of n bytes.n must be a value from 1 through 8,000.

varchar(n)variable length non unicode character data with length of n bytes.

nvarchar(n)variable length unicode character data of n characters. n must be a value from 1 through 4,000.

23.
How many types of triggers are there?

There are three types of triggers.
§  DML Triggers
--> AFTER Triggers
--> INSTEAD OF Triggers
§  DDL Triggers
§  CLR Triggers


SQL Server Interview Question And Anser For Fresher And Experience Part 3

1.
What is NOT NULL Constraint?

A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints.

2.
What is log shipping?

Log shipping is the process of automating the backup of database and transaction log files on a production SQL server, and then restoring them onto a standby server. Enterprise Editions only supports log shipping. In log shipping the transactional log file from one server is automatically updated into the backup database on the other server.

3.
What is Cross Join?

A cross join that does not have a WHERE clause produces the Cartesian product of the tables involved in the join. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table.

4.
What is Self Join?

A self join can be of any type, as long as the joined tables are the same. A self join is rather unique in that it involves a relationship with only one table.

5.
What is a default constraint?

A default constraint is a value that SQL Server automatically places in a particular field in a table.
6.
What is the difference between Triggers and Stored Procedure?

Stored Procedures are called by the programmer wherever it wants to fire but triggers fired automatically when insert,delete,update occured. And triggers can be implemented to tables & views only where as stored procedure used in the database independently.

7.
What are the properties of Sub–Query?

§  A subquery must be enclosed in the parenthesis.
§  A subquery must be put in the right hand of the comparison operator
§  A subquery cannot contain a ORDER-BY clause.
§  A query can contain more than one sub-queries.

8.
Where are SQL server users names and passwords are stored in sql server?

They get stored in master db in the sysxlogins table.

9.
What are the types of subscriptions in SQL Server replication?

There are two types of replication in sql server are :
§  Push
§  Pull

10.
What does REVERT do in SQL Server 2005?

Restores your previous execution context.If you have changed your execution context with EXECUTE AS, the REVERT statement will restore the last context prior to the EXECUTE AS.
11.
What is the difference between system objects and user objects?

§  SQL Server creates system objects during the installation process.
§  They are part of the system, and most of them are necessary for SQL Server to function properly.
§  Whereas system objects are part of the SQL Server system, you create user objects.
§  User objects include the databases, stored procedures, functions, and other system objects that you build.

12.
Who is responsible for backing up SQL Server databases?

SQL Server administrator.

13.
What is a Server Role?

A server role is pre-defined by SQL Server. It possesses a pre-defined set of rights.

14.
What is the name of the system variable that returns the number of rows affected by a SQL statement?

@@ROWCOUNT.

15.
What keyword do you use to return a value from a stored procedure?

The OUTPUT keyword.

16.
What are different type of Collation Sensitivity?

The different phases of transaction are : 

§  Case sensitivity
§  Accent sensitivity
§  Kana Sensitivity
§  Width sensitivity

17.
What is the difference between a check constraint and a rule?

Check constraints and rules limit the range of values that a user can enter into a column. Whereas check constraints apply only to the table for which you enter them, you can apply rules to multiple tables.

18.
What function extracts specified characters from a string?

The SUBSTRING function extracts specified characters from a string.

19.
What is the difference between TRUNCATE and DROP?

TRUNCATE removes all data from the table while retaining the table structure, whereas DROP removes the table from the database.

20.
What are the different types of cursor?

There are three types of cursors :
§  Implicit cursors
§  Explicit cursors
§  Paramaeteried cursors