Friday, May 29, 2015

Asp.net Create an error log file

Introduction: In this article I will explain how to create an error log file in asp.net

Description:
Error log file is useful to capture runtime errors and exceptions of website to a file. In this example I will create a text error log file. Follow the below given steps to implement:

Tuesday, May 26, 2015

List all CONSTRAINT of database or table in Sql Server

Introduction: In this article today I am going to explain how we can list all CONSTRAINT of database or table in Sql Server

Description:
When we are working on database sometimes we need to check or get the CONSTRAINT on database or table. Using below given query we can get the CONSTRAINT of table or database quickly.

Query to list all fields of sys.objects:
SELECT * FROM sys.objects WHERE type_desc LIKE '%CONSTRAINT'

Using above query we get all fields of sys.objects.

To get only Constraint name, tabe name and Constraint type I use the refined query mention below:
SELECT OBJECT_NAME(object_id) AS ConstraintName,
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT'

List all CONSTRAINT of database


To get the Constraint detail of a particular table use the below given query:
SELECT OBJECT_NAME(object_id) AS ConstraintName,
SCHEMA_NAME(schema_id) AS SchemaName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT' AND OBJECT_NAME(parent_object_id)='Student_Register'
List all CONSTRAINT of database
Replace the Student_Register with your database table name.


Thursday, May 21, 2015

Difference between ViewBag, ViewData and TempData in mvc

Introduction: In this article today I am going to explain what is the difference between ViewBag, ViewData and TempData in mvc

We use the ViewData, ViewBag and TempData to pass data from controller to view. ViewBag and ViewData are almost similar.

ViewData:

ViewData is a dictionary object that is derived from ViewDataDictionary class and accessible using strings as key values. It is used to pass data from controller to view. It requires typecasting for a complex data type and check for null values to avoid error. ViewData has short life because its life lies during current request only. If redirection occurs its value become null. ViewData is faster than ViewBag.

Wednesday, May 20, 2015

Different types of keys in Sql server

A key is a single or combination of multiple fields. Its purpose is to access or retrieve data rows from table according to the requirement. The keys are defined in tables to access or sequence the stored data quickly and smoothly. They are also used to create links between different tables.

1.  Super key: A super key is a combination of an attribute or set of attributes that uniquely identify a record in a table. A table might have many superkeys. Primary key, Unique key, Alternate key are subset of Super Keys.

2.  Primary key: A primary key uniquely identifies each record and prevents the duplicate values for a column or columns in a database table. Primary key column can't have null values. Each table can have only one Primary key and it creates clustered index on the column or columns. Read more about Primary key

Monday, May 18, 2015

MVC Webgrid with paging and sorting

Introduction: In this article today I am going to explain how to implement the sorting and paging in MVC webgrid

Description:
In the last article I explained
To implement the sorting and paging in Webgrid we have to assign the canSort, canPage and rowsPerPage parameter. In this example I want to display the 2 rows per page.


WebGrid grid = new WebGrid(Model,canSort:true,canPage:true,rowsPerPage:2);

Index.cshtml :-
@model IEnumerable<UserRegistration.Models.User_Registration>

@{
    ViewBag.Title = "Users Detail";
    WebGrid grid = new WebGrid(Model,canSort:true,canPage:true,rowsPerPage:2);
}
<style type="text/css">
table
{
width:100%;
}
th
{
padding: 2px 2px 2px;
}
td
 {
  text-align:center;
}
</style>
<h2>Users Detail</h2>

@grid.GetHtml(
    tableStyle: "table",
    fillEmptyRows: true,    
    headerStyle: "false",  
    footerStyle: "false",
    mode: WebGridPagerModes.All,
    firstText: "<< First",
    previousText: "< Previous",
    nextText: "Next >",
    lastText: "Last >>",
   
    columns: new[]
    {
        //the model fields to display
        grid.Column("User_Name","UserName"),
        grid.Column("First_Name","First Name"),
        grid.Column("Last_Name","Last Name"),
        grid.Column(header:"Profile Image", format: @<text><img src="@Url.Content(item.Profile_Image)" alt="Image" height="100px" width="100px" /></text>),
        grid.Column("EmailId","EmailId"),
        grid.Column("Sex","Sex"),
        grid.Column("Master_Qualification.Qualification","Qualification"),
        grid.Column("Master_Country.Country_Name","Country Name"),
        grid.Column("Phone_No","Phone No"),
   }
) 

Build the project and run.

 Is this article helpful for you?

If yes post your comment to appreciate my work and fell free to contact me. 

Saturday, May 16, 2015

Foreign Key constraint in Sql server

Introduction: In this article today ia m going to explain foreign Key constraint in sql server

Description:
A foreign key Constraint is used to link two tables together. A Foreign key in one table refers to primary key of another table.  It can accept multiple null and duplicate values.

Thursday, May 14, 2015

Unique Key in Sql server

Introduction: In this article today I am going to explain Unique Key in Sql server

Description:
Unique Key as name describe only one of its kind means uniquely identifies each record in a database table. It is like a primary key and does not allow the duplicates values in column or columns. The main difference is Unique key allow only one null value and primary key doesn't allow null value. Unique Key by default create a non-clustered index. We can have multiple Unique Keys per table but only have one primary key.

Wednesday, May 13, 2015

Primary key constraint in sql server

Introduction: In this article today I am going to explain Primary key constraint in sql server

Description:
A primary key constraint uniquely identifies each record and prevents the duplicate values for a column or columns in a database table. Primary key column can't have null values. Each table can have only one Primary key and it creates clustered index on the column or columns.

Tuesday, May 12, 2015

How to set up video in background using css

Introduction: In this article today I am going to explain how to set up or play video in background using css

Description:
You have seen video being used as a background. We can set up the video in background in few steps.
Add the below given style to html page:

<style>
body{ margin:0px;);}
video#bg {
position: fixed; right: 0; bottom: 0;
min-width: 100%; min-height: 100%;
width: auto; height: auto; z-index: -100;
background: url(polina.jpg) no-repeat;
background-size: cover;
}
#bg_container{ height:500px; overflow:hidden; }
#content{ position:absolute; top:0px; padding:30px; color:#000;}
</style>

After that write the below given code and give the path of video that you want to play in background.

<div id="bg_container">
  <video id="bg" src="cloud.mp4" autoplay loop muted="true"></video> 
</div>
<div id="content">
<h2>Play video in Background</h2>
<h1>Visit <a href="http://www.articlemirror.in/">Articlemirror</a> for more tutorials</h1>
</div>

Complete code of HTML page:
<html>
<head>
<style>
body{ margin:0px;);}
video#bg {
position: fixed; right: 0; bottom: 0;
min-width: 100%; min-height: 100%;
width: auto; height: auto; z-index: -100;
background: url(polina.jpg) no-repeat;
background-size: cover;
}
#bg_container{ height:500px; overflow:hidden; }
#content{ position:absolute; top:0px; padding:30px; color:#000;}
</style>
</head>
<body>
<div id="bg_container">
  <video id="bg" src="cloud.mp4" autoplay loop muted="true"></video> 
</div>
<div id="content">
<h2>Play video in Background</h2>
<h1>Visit <a href="http://www.articlemirror.in/">Articlemirror</a> for more tutorials</h1>
</div>
</body>
</html> 
download


Friday, May 8, 2015

Sql server Temporary tables

Introduction: In this article today I am going to explain the Temporary tables in sql server

Description:
Temporary tables are created at runtime and we can do all operation which we can do on a normal table. Temporary tables are stored in System Databases >> tempdb database.
Sql server Temporary tables

Wednesday, May 6, 2015

How to disable the link using CSS

Introduction: In this article today I am going to explain how to disable the link using CSS

Description:
We can disable the active links using pointer events in css.
I create a class .not-active to disable the link:

.not-active
{
pointer-events: none;
cursor: default;
}

After that define the class for anchor tag
<a href="http://articlemirror.in" class="not-active">Articlemirror</a>

Tuesday, May 5, 2015

Count duplicate rows or records in Sql server

Introduction: In this article today I am going to explain how to count all duplicate rows/records in the table in Sql server

Description:


To count the duplicate records of each below run the below given query:

Saturday, May 2, 2015

How to find duplicate records in a table in SQL server

Introduction: In this article today I am going to explain how to find duplicate records in a table in SQL server

Description:

I have a table Student_Detail and having duplicate records.
  
find duplicate records in a table in SQL server


We can find the duplicate records of table using Group by clause. To find the duplicate records of table use the below given Query: