ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language.
Tuesday, July 24, 2012
Sql Query - "0" for Inactive "1' for Active
select *, case status when '1' then 'Active' when '0' then 'In-Active' end as Status1 from tblArticleMasterDestination order by Destname
Labels:
Asp.net
Dal Class-lIbrary
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
public sealed class DAL
{
private DAL() { }
private static void AttachParameters(SqlCommand command, SqlParameter[] commandParameters)
{
foreach (SqlParameter p in commandParameters)
{
if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
{
p.Value = DBNull.Value;
}
command.Parameters.Add(p);
}
}
private static void AssignParameterValues(SqlParameter[] commandParameters, object[] parameterValues)
{
if ((commandParameters == null) || (parameterValues == null))
{
return;
}
if (commandParameters.Length != parameterValues.Length)
{
throw new ArgumentException("Parameter count does not match Parameter Value count.");
}
for (int i = 0, j = commandParameters.Length; i < j; i++)
{
commandParameters[i].Value = parameterValues[i];
}
}
private static void PrepareCommand(SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters)
{
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
command.Connection = connection;
command.CommandText = commandText;
if (transaction != null)
{
command.Transaction = transaction;
}
command.CommandType = commandType;
if (commandParameters != null)
{
AttachParameters(command, commandParameters);
}
return;
}
public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteNonQuery(cn, commandType, commandText, commandParameters);
}
}
public static int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
}
}
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
cmd.CommandTimeout = 120;
int retval = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return retval;
}
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteDataset(cn, commandType, commandText, commandParameters);
}
}
public static DataSet ExecuteDataset(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
}
}
public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
cmd.CommandTimeout = 120;
da.Fill(ds);
cmd.Parameters.Clear();
return ds;
}
public static DataTable ExecuteDatatable(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteDatatable(cn, commandType, commandText, commandParameters);
}
}
public static DataTable ExecuteDatatable(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteDatatable(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteDatatable(connectionString, CommandType.StoredProcedure, spName);
}
}
public static DataTable ExecuteDatatable(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
cmd.Parameters.Clear();
return dt;
}
public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteScalar(cn, commandType, commandText, commandParameters);
}
}
public static object ExecuteScalar(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
}
}
public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
cmd.CommandTimeout = 120;
object retval = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return retval;
}
}
public sealed class SqlHelperParameterCache
{
private SqlHelperParameterCache() { }
private static Hashtable paramCache = Hashtable.Synchronized(new Hashtable());
private static SqlParameter[] DiscoverSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)
{
using (SqlConnection cn = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand(spName, cn))
{
cn.Open();
cmd.CommandType = CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(cmd);
if (!includeReturnValueParameter)
{
cmd.Parameters.RemoveAt(0);
}
SqlParameter[] discoveredParameters = new
SqlParameter[cmd.Parameters.Count];
cmd.Parameters.CopyTo(discoveredParameters, 0);
return discoveredParameters;
}
}
private static SqlParameter[] CloneParameters(SqlParameter[] originalParameters)
{
SqlParameter[] clonedParameters = new SqlParameter[originalParameters.Length];
for (int i = 0, j = originalParameters.Length; i < j; i++)
{
clonedParameters[i] = (SqlParameter)
((ICloneable)originalParameters[i]).Clone();
}
return clonedParameters;
}
public static void CacheParameterSet(string connectionString, string commandText, params SqlParameter[] commandParameters)
{
string hashKey = connectionString + ":" + commandText;
paramCache[hashKey] = commandParameters;
}
public static SqlParameter[] GetCachedParameterSet(string connectionString, string commandText)
{
string hashKey = connectionString + ":" + commandText;
SqlParameter[] cachedParameters = (SqlParameter[])paramCache[hashKey];
if (cachedParameters == null)
{
return null;
}
else
{
return CloneParameters(cachedParameters);
}
}
public static SqlParameter[] GetSpParameterSet(string connectionString, string spName)
{
return GetSpParameterSet(connectionString, spName, false);
}
public static SqlParameter[] GetSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)
{
string hashKey = connectionString + ":" + spName + (includeReturnValueParameter ? ":include ReturnValue Parameter" : "");
SqlParameter[] cachedParameters;
cachedParameters = (SqlParameter[])paramCache[hashKey];
if (cachedParameters == null)
{
cachedParameters = (SqlParameter[])(paramCache[hashKey] = DiscoverSpParameterSet(connectionString, spName, includeReturnValueParameter));
}
return CloneParameters(cachedParameters);
}
}
using System.Data;
using System.Data.SqlClient;
using System.Collections;
public sealed class DAL
{
private DAL() { }
private static void AttachParameters(SqlCommand command, SqlParameter[] commandParameters)
{
foreach (SqlParameter p in commandParameters)
{
if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
{
p.Value = DBNull.Value;
}
command.Parameters.Add(p);
}
}
private static void AssignParameterValues(SqlParameter[] commandParameters, object[] parameterValues)
{
if ((commandParameters == null) || (parameterValues == null))
{
return;
}
if (commandParameters.Length != parameterValues.Length)
{
throw new ArgumentException("Parameter count does not match Parameter Value count.");
}
for (int i = 0, j = commandParameters.Length; i < j; i++)
{
commandParameters[i].Value = parameterValues[i];
}
}
private static void PrepareCommand(SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters)
{
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
command.Connection = connection;
command.CommandText = commandText;
if (transaction != null)
{
command.Transaction = transaction;
}
command.CommandType = commandType;
if (commandParameters != null)
{
AttachParameters(command, commandParameters);
}
return;
}
public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteNonQuery(cn, commandType, commandText, commandParameters);
}
}
public static int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
}
}
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
cmd.CommandTimeout = 120;
int retval = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return retval;
}
public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteDataset(cn, commandType, commandText, commandParameters);
}
}
public static DataSet ExecuteDataset(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
}
}
public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
cmd.CommandTimeout = 120;
da.Fill(ds);
cmd.Parameters.Clear();
return ds;
}
public static DataTable ExecuteDatatable(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteDatatable(cn, commandType, commandText, commandParameters);
}
}
public static DataTable ExecuteDatatable(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteDatatable(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteDatatable(connectionString, CommandType.StoredProcedure, spName);
}
}
public static DataTable ExecuteDatatable(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
cmd.Parameters.Clear();
return dt;
}
public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open();
return ExecuteScalar(cn, commandType, commandText, commandParameters);
}
}
public static object ExecuteScalar(string connectionString, string spName, params object[] parameterValues)
{
if ((parameterValues != null) && (parameterValues.Length > 0))
{
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
}
}
public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
cmd.CommandTimeout = 120;
object retval = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return retval;
}
}
public sealed class SqlHelperParameterCache
{
private SqlHelperParameterCache() { }
private static Hashtable paramCache = Hashtable.Synchronized(new Hashtable());
private static SqlParameter[] DiscoverSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)
{
using (SqlConnection cn = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand(spName, cn))
{
cn.Open();
cmd.CommandType = CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(cmd);
if (!includeReturnValueParameter)
{
cmd.Parameters.RemoveAt(0);
}
SqlParameter[] discoveredParameters = new
SqlParameter[cmd.Parameters.Count];
cmd.Parameters.CopyTo(discoveredParameters, 0);
return discoveredParameters;
}
}
private static SqlParameter[] CloneParameters(SqlParameter[] originalParameters)
{
SqlParameter[] clonedParameters = new SqlParameter[originalParameters.Length];
for (int i = 0, j = originalParameters.Length; i < j; i++)
{
clonedParameters[i] = (SqlParameter)
((ICloneable)originalParameters[i]).Clone();
}
return clonedParameters;
}
public static void CacheParameterSet(string connectionString, string commandText, params SqlParameter[] commandParameters)
{
string hashKey = connectionString + ":" + commandText;
paramCache[hashKey] = commandParameters;
}
public static SqlParameter[] GetCachedParameterSet(string connectionString, string commandText)
{
string hashKey = connectionString + ":" + commandText;
SqlParameter[] cachedParameters = (SqlParameter[])paramCache[hashKey];
if (cachedParameters == null)
{
return null;
}
else
{
return CloneParameters(cachedParameters);
}
}
public static SqlParameter[] GetSpParameterSet(string connectionString, string spName)
{
return GetSpParameterSet(connectionString, spName, false);
}
public static SqlParameter[] GetSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)
{
string hashKey = connectionString + ":" + spName + (includeReturnValueParameter ? ":include ReturnValue Parameter" : "");
SqlParameter[] cachedParameters;
cachedParameters = (SqlParameter[])paramCache[hashKey];
if (cachedParameters == null)
{
cachedParameters = (SqlParameter[])(paramCache[hashKey] = DiscoverSpParameterSet(connectionString, spName, includeReturnValueParameter));
}
return CloneParameters(cachedParameters);
}
}
Labels:
Asp.net
Active/Inactive
In Gridview Define templatefield inside column
<asp:GridView ID="gvContent" runat="server" CssClass="body-text-black" Width="750px" AllowPaging="True" AutoGenerateColumns="False" HeaderStyle-CssClass="gridhead" CellPadding="5" RowStyle-CssClass="gridrow1" AlternatingRowStyle-CssClass="gridrow2" BorderWidth="0px" GridLines="None" HeaderStyle-VerticalAlign="top" HorizontalAlign="Left" HeaderStyle-HorizontalAlign="left" RowStyle-VerticalAlign="top" onpageindexchanging="gvContent_PageIndexChanging" onrowcommand="gvContent_RowCommand" PageSize=30 onrowdatabound="gvContent_RowDataBound"><Columns>
<asp:TemplateField HeaderText="S.No.">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %> </ItemTemplate>
</asp:TemplateField>
<asp:templatefield headertext="Active/InActive">
<itemtemplate>
<asp:button causesvalidation="false" commandargument="<%#Eval("DestID")%>" commandname="Status" cssclass="btn" id="btnStatus" onclientclick="return
ConfirmStatus()" runat="server" text="<%#Eval("Status1")%>"> </asp:button>
</itemtemplate>
</asp:templatefield>
</Columns>
</asp:GridView>
I have used command name and command arguement and it will handle inside rowcommand event.
Row command Code of Cs page
protected void gvContent_RowCommand(object sender, GridViewCommandEventArgs e){
if (e.CommandName == "Status")
{
int index = Convert.ToInt32(e.CommandArgument.ToString());
try
{
int iRow = DAL.ExecuteNonQuery(ConnectionString, "prcDesttemp", "4", index, "","", "", "", "","", "","","","","", "1", "0" ,0, 0 ,0,"0"); Fillgridview(); lblMsg.Text = "Status Changed Successfully.";
}
catch (Exception ex)
{ }
}
}
I have used pocedure to do this task -which is easy to maintain.And used a Dal Class for this where i am passing connection string , procedure name, action Id and parameter.
CREATE procedure [dbo].[prcDesttemp]
(
@ActionId tinyint,
@DestID int,
@DestName nvarchar(100),
@DestiShortDesc nvarchar (200),
@DestiLongDesc text,
@PlaceDesc text,
@WeatherDesc text,
@HistoryDesc text,
@VisitDesc text,
@SmallImage nvarchar(200),
@LongImage nvarchar(200),
@MetaTitle text,
@MetaDesc text, @Status tinyint ,
@Result tinyint output,
@RegionID int,
@CountryID int,
@CityID int ,
@Displayonhome tinyint
)
--sp_help tblArticleMasterClient
as
begin
set nocount on
if @ActionId=1 --Add Destination
begin
insert into tblArticleMasterDestination (DestName,DestiShortDesc,DestiLongDesc,PlaceDesc,WeatherDesc, HistoryDesc, VisitDesc,SmallImage,LongImage,MetaTitle,MetaDesc,Status,CreateDate , RegionID , CountryID , CityID,Displayonhome ) values (@DestName, @DestiShortDesc, @DestiLongDesc,@PlaceDesc, @WeatherDesc, @HistoryDesc, @VisitDesc, @SmallImage , @LongImage , @MetaTitle, @MetaDesc, '1', getdate() , @RegionID , @CountryID , @CityID,@Displayonhome)
end
if @ActionId=2 --Update Destination
begin
update tblArticleMasterDestination set
DestName = @DestName,
DestiShortDesc = @DestiShortDesc ,
DestiLongDesc = @DestiLongDesc ,
PlaceDesc = @PlaceDesc ,
WeatherDesc=@WeatherDesc,
HistoryDesc=@HistoryDesc,
VisitDesc=@VisitDesc,
SmallImage=@SmallImage,
LongImage=@LongImage,
MetaTitle=@MetaTitle,
MetaDesc=@MetaDesc,
UpdateDate = getdate()
, RegionID = @RegionID ,
CountryID = @CountryID ,
CityID = @CityID
where DestID = @DestID
end
if @ActionId=3 --Select records
begin
select *, case status when '1' then 'Active' when '0' then 'In-Active' end as Status1 from tblArticleMasterDestination order by Destname end
if @ActionId=4 --Change Status
begin
select @Status=Status from tblArticleMasterDestination where DestID=@DestID
if @Status=0 --InActive
begin
Update tblArticleMasterDestination set Status=1 where DestID=@DestID end
else --Active
begin
update tblArticleMasterDestination set Status=0 where DestID=@DestID end
end end --set nocount off end
Get Dal class And copy it and put this in app_code library
Labels:
Asp.net
Monday, July 23, 2012
Database Normalization Basics
Normalization or data normalization is a process to organize the data into tabular format (database tables). A good database design includes the normalization, without normalization a database system may slow, inefficient and might not produce the expected result. Normalization reduces the data redundancy and inconsistent data dependency.
Normal Forms
We organize the data into database tables by using normal forms rules or conditions. Normal forms help us to make a good database design. Generally we organize the data up to third normal form. We rarely use the fourth and fifth normal form.To understand normal forms consider the folowing unnormalized database table. Now we will normalize the data of below table using normal forms.
First Normal Form (1NF)
A database table is said to be in 1NF if it contains no repeating fields/columns. The process of converting the UNF table into 1NF is as follows:
- Separate the repeating fields into new database tables along with the key from unnormalized database table.
- The primary key of new database tables may be a composite key
Second Normal Form (2NF)
A database table is said to be in 2NF if it is in 1NF and contains only those fields/columns that are functionally dependent(means the value of field is determined by the value of another field(s)) on the primary key. In 2NF we remove the partial dependencies of any non-key field.
The process of converting the database table into 2NF is as follows:- Remove the partial dependencies(A type of functional dependency where a field is only functionally dependent on the part of primary key) of any non-key field.
- If field B depends on field A and vice versa. Also for a given value of B, we have only one possible value of A and vice versa, Then we put the field B in to new database table where B will be primary key and also marked as foreign key in parent table.
Third Normal Form (3NF)
A database table is said to be in 3NF if it is in 2NF and all non keys fields should be dependent on primary key or We can also said a table to be in 3NF if it is in 2NF and no fields of the table is transitively functionally dependent on the primary key.The process of converting the table into 3NF is as follows:
- Remove the transitive dependecies(A type of functional dependency where a field is functionally dependent on the Field that is not the primary key.Hence its value is determined, indirectly by the primary key )
- Make separate table for transitive dependent Field.
Boyce Code Normal Form (BCNF)
A database table is said to be in BCNF if it is in 3NF and contains each and every determinant as a candidate key.The process of converting the table into BCNF is as follows:
- Remove the non trival functional dependency.
- Make separate table for the determinants.
Fourth Normal Form (4NF)
A database table is said to be in 4NF if it is in BCNF and primary key has one-to-one relationship to all non keys fields or We can also said a table to be in 4NF if it is in BCNF and contains no multi-valued dependencies.The process of converting the table into 4NF is as follows:
- Remove the multivalued dependency.
- Make separate table for multivalued Fields.
Fifth Normal Form (5NF)
A database table is said to be in 5NF if it is in 4NF and contains no redundant values or We can also said a table to be in 5NF if it is in 4NF and contains no join dependencies.The process of converting the table into 5NF is as follows:
- Remove the join dependency.
- Break the database table into smaller and smaller tables to remove all data redundancy.
Summary
In this article I try to explain the Normalization with example. I hope after reading this article you will be able to understand Normal Forms. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.
Labels:
Asp.net
Introduction to SVN
SVN is an open source version control system that is broadly used by many organizations for its project history. It is free to use and manage source code different versions. You can find below two types of svn.
Ankh SVN is a open source subversion Source control for Visual Studio for managing your's code different versions like VSS and TFS. Tortoise SVN is also a open source subversion Source control for managing your's source code versions. Your source code could be in any language and could support window or unix or apache platform
It has the following listed features:-
- SVN tracks the structure of all folders present in your project.
- It assigns a global revision number to your source code repository that is used to manage your source code history.
- SVN commits and updates are atomic.
- SVN maintains the revision history of moved or copied files.
- SVN can be installed on Window, Unix and Apache platform.
- SVN Client and SVN Server are used to manage source code versions. SVN Server version is installed on Server and SVN Client version is installed on Client side.
You can go to this link for installing and managing Tortoise SVN on your computer.
Example to get file size before upload using JQuery
Example to get file size before upload using JQuery
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Get File Size</title> <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript" > </script> <script type="text/javascript"> function GetFileSize(fileid) { try { var fileSize = 0; //for IE if ($.browser.msie) { //before making an object of ActiveXObject, //please make sure ActiveX is enabled in your IE browser var objFSO = new ActiveXObject("Scripting.FileSystemObject"); var filePath = $("#" + fileid)[0].value; var objFile = objFSO.getFile(filePath); var fileSize = objFile.size; //size in kb fileSize = fileSize / 1048576; //size in mb } //for FF, Safari, Opeara and Others else { fileSize = $("#" + fileid)[0].files[0].size //size in kb fileSize = fileSize / 1048576; //size in mb } alert("Uploaded File Size is" + fileSize + "MB"); } catch (e) { alert("Error is :" + e); } } </script> </head> <body> <form name="upload" action=""> <input type="file" name="fUpload" id="fUpload" /> <input type="button" value="Get File Size" onclick="GetFileSize('fUpload');" /> </form> </body> </html>
Example to get file size before upload in Asp.Net using JQuery
Using above defined function "GetFileSize", we can also get file size in Asp.net also like as :<form id="form1" runat="server"> <asp:FileUpload ID="fUpload" runat="server" /> <asp:Button ID="btnGetSize" runat="server" Text="Button" OnClientClick="GetFileSize('fUpload');" /> </form>
Labels:
Jquery
Wednesday, July 18, 2012
What is IT ? IT is JUGAAD.
I am always a student and I enjoy being Student. I want to learn almost everything about Computer Science that exists. So I keep trying at home, office, even while I sleep.
Since two yr of job My senior is a Web developer . He is one of the Extremely talented Developers I have ever met.
IT is short form of Information Technology and Related to Computer and Digital world. Everything inside Digital world can be taken inside IT.
According to him what i understand most is that IT is jugaad (Trick/hacks) to solve the different problem by different ways.
Labels:
Asp.net
How to Access My Windows 7 Laptop without Admin Password
It's a good habit to set a password on your computer so that people
can not enter windows without knowing your password. But if you forgot
Windows 7 password, you'll also be prevented from logging in. How to
reset Windows 7 password if you forgot Windows password and can't log on
using any administrator account?
In this article I'll cover the most two popular and efficient Windows 7 password recovery programs for you to reset Windows 7 login password, even if you can't get into Windows system. Let's know how can we achieve it.
1. Ophcrack
The Ophcrack is a free Windows password cracker based on rainbow tables. It is a very efficient implementation of rainbow tables done by the inventors of the method. It comes with a Graphical User Interface and runs on multiple platforms. By far, it is the most popular free way for password recovery on Windows 7.
With Ophcrack, you don't need any access to Windows system to be able to recover your lost passwords. Simply visit the site, download the free ISO image, burn it to a CD and boot from the CD. The Ophcrack program starts, locates the Windows user accounts, and proceeds to recover (crack) the passwords.
Before trying it, the following 2 things you should learn about the free Windows password hack:
1. 496MB (7/Vista) / 415MB (XP) LiveCD ISO image will take you much time for download.
2. Passwords greater than 14 characters cannot be cracked.
If this free Windows password cracker doesn't work for you, a good alternative option is to get Windows Password Unlocker.
2. Window Password Unlocker
Windows Password Unlocker is a professional Windows password reset tool. When Windows forgot password, this powerful utility allows you to remove the forgotten password by burning a bootable password reset USB, instead of recovering it.
Requirements:
1. A blank CD/DVD and CD-ROM¡ÀRW drive are required
2. Download and install this software in a Windows PC rather than a Mac.
Steps:
1. Download and install Windows Password Unlocker
2. Burn a password reset disk with a bootable CD/DVD
3. Reset Windows password with created CD/DVD reset disk
After the password reset success, you can access your computer without entering a password. The whole password reset process is in 5 minutes, and has no damage to your computer. Windows Password Unlocker enjoys great popularity among forgotten Windows password users. Through this powerful application, you can easily reset a forgotten laptop administrator password in 5 minutes instead of recovering it in hours by Ophcrack.
In this article I'll cover the most two popular and efficient Windows 7 password recovery programs for you to reset Windows 7 login password, even if you can't get into Windows system. Let's know how can we achieve it.
1. Ophcrack
The Ophcrack is a free Windows password cracker based on rainbow tables. It is a very efficient implementation of rainbow tables done by the inventors of the method. It comes with a Graphical User Interface and runs on multiple platforms. By far, it is the most popular free way for password recovery on Windows 7.
With Ophcrack, you don't need any access to Windows system to be able to recover your lost passwords. Simply visit the site, download the free ISO image, burn it to a CD and boot from the CD. The Ophcrack program starts, locates the Windows user accounts, and proceeds to recover (crack) the passwords.
Before trying it, the following 2 things you should learn about the free Windows password hack:
1. 496MB (7/Vista) / 415MB (XP) LiveCD ISO image will take you much time for download.
2. Passwords greater than 14 characters cannot be cracked.
If this free Windows password cracker doesn't work for you, a good alternative option is to get Windows Password Unlocker.
2. Window Password Unlocker
Windows Password Unlocker is a professional Windows password reset tool. When Windows forgot password, this powerful utility allows you to remove the forgotten password by burning a bootable password reset USB, instead of recovering it.
Requirements:
1. A blank CD/DVD and CD-ROM¡ÀRW drive are required
2. Download and install this software in a Windows PC rather than a Mac.
Steps:
1. Download and install Windows Password Unlocker
2. Burn a password reset disk with a bootable CD/DVD
3. Reset Windows password with created CD/DVD reset disk
After the password reset success, you can access your computer without entering a password. The whole password reset process is in 5 minutes, and has no damage to your computer. Windows Password Unlocker enjoys great popularity among forgotten Windows password users. Through this powerful application, you can easily reset a forgotten laptop administrator password in 5 minutes instead of recovering it in hours by Ophcrack.
Labels:
tricks
Friday, July 13, 2012
Url Rewritting in 2.0
urlMappings redirect URLs to new locations. This element is part of an ASP.NET config file. It quickly redirects Googlebot and users alike to the new locations. It is easily added to Web.config to perform this complex task.
Now in the web config file you can put below code in between <system.web> and</system.web>
<urlMappings enabled="true" >
<!--url which you want mappedURL = transfered url location -->
<add mappedUrl="~/Detail.aspx?id=1" url="~/one.aspx"/>
<add mappedUrl="~/Detail.aspx?id=2" url="~/two.aspx"/>
<add mappedUrl="~/Detail.aspx?id=3" url="~/three.aspx"/>
<add mappedUrl="~/Detail.aspx?id=4" url="~/four.aspx"/>
</urlMappings>
mappedurl= mapping applied on this url
Url=which is not available but stilll you made it to appear.
Now in the web config file you can put below code in between <system.web> and</system.web>
<urlMappings enabled="true" >
<!--url which you want mappedURL = transfered url location -->
<add mappedUrl="~/Detail.aspx?id=1" url="~/one.aspx"/>
<add mappedUrl="~/Detail.aspx?id=2" url="~/two.aspx"/>
<add mappedUrl="~/Detail.aspx?id=3" url="~/three.aspx"/>
<add mappedUrl="~/Detail.aspx?id=4" url="~/four.aspx"/>
</urlMappings>
mappedurl= mapping applied on this url
Url=which is not available but stilll you made it to appear.
Labels:
Asp.net
Tuesday, July 3, 2012
Virtual keywords use in C#
Introduction:A virtual keyword is used to modify a method property event declaration and allow to be overridden in a derived class. in this program the class dimensions contain the two coordinates a,b and the area()virtual method.diffrent shape class such as circle cylinder and sphere inherit the dimensions class and the surface area is calculated for each figure.
Example:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TestClass
{
public class Dimensions
{
public const double PI = Math.PI;
protected double a, b;
public Dimensions()
{
}
public Dimensions(double a, double b)
{
this.a = a;
this.b = b;
}
public virtual double Area()
{
return a*b;
}
}
public class Circle : Dimensions
{
public Circle(double r)
: base(r, 0)
{
}
public override double Area()
{
return PI * a * b;
}
}
class Sphere : Dimensions
{
public Sphere(double r)
: base(r, 0)
{
}
public override double Area()
{
return 100 * PI * a * a;
}
}
class Cylinder : Dimension
{
public Cylinder(double r, double h)
: base(r, h)
{
}
public override double Area()
{
return 2 * PI * a * a + 8 * PI * a * b;
}
}
static void Main()
{
double r = 10.0, h = 8.0;
Dimensions c = new Circle(r);
Dimensions s = new Sphere(r);
Dimensions l = new Cylinder(r, h);
Console.WriteLine("Area of Circle = {0:F2}", c.Area());
Console.WriteLine("Area of Sphere = {0:F2}", s.Area());
Console.WriteLine("Area of Cylinder = {0:F2}", 1.Area());
}
}
Output:
Labels:
Asp.net
How to Hack Windows Administrator Password
Here is another simple way through which you can reset the password of any non-administrator accounts. The only requirement for this is that you need to have administrator privileges. Here is a step-by-step instruction to accomplish this task.
1. Open the command prompt (Start->Run->type cmd->Enter)
2. Now type net user and hit Enter
3. Now the system will show you a list of user accounts on the computer. Say for example you need to reset the password of the account by name John, then do as follows
4. Type net user John * and hit Enter. Now the system will ask you to enter the new password for the account. That’s it. Now you’ve successfully reset the password for John without knowing his old password.
So in this way you can reset the password of any Windows account at times when you forget it so that you need not re-install your OS for any reason. I hope this helps.
1. Open the command prompt (Start->Run->type cmd->Enter)
2. Now type net user and hit Enter
3. Now the system will show you a list of user accounts on the computer. Say for example you need to reset the password of the account by name John, then do as follows
4. Type net user John * and hit Enter. Now the system will ask you to enter the new password for the account. That’s it. Now you’ve successfully reset the password for John without knowing his old password.
So in this way you can reset the password of any Windows account at times when you forget it so that you need not re-install your OS for any reason. I hope this helps.
Labels:
tricks
Install windows xp in less than 15 minutes
- Boot through windows xp cd
- After all the files are completely loaded,you get the option to select the partition. Select “c:”
- Now format the partition,whether it is normal or quick with NTFS or FAT
- Once the formatting is completed, All the setup files required for installation are copied. Restart your system by pressing Enter.
- Now here begins the simple trick to save 15 minutes.
- After rebooting , you get a screen where it takes 40 minutes to complete or finalize OS installation
- now press Shift + F10 Key. This opens command Prompt.
- Enter “taskmgr” at the command prompt window. This will open task manager
- Click the process Tab, here we find a process called Setup.exe . Right click on Setup.exe-> Set priority – > Select High or Above normal. Initially it will be Normal
Labels:
tricks
Subscribe to:
Posts (Atom)