Difference between 32-bit and 64-bit Windows

What is the difference between 32-bit and 64-bit versions of Windows?
The terms 32-bit and 64-bit refer to the way a computer’s processor (also called a CPU), handles information. The 64-bit version of Windows handles large amounts of random access memory (RAM) more effectively than a 32-bit system.

How can I tell if my computer is running a 32-bit or a 64-bit version of Windows?
To find out if your computer is running a 32-bit or 64-bit version of Windows in Windows 7 or Windows Vista, do the following:

  • Open System by clicking the Start button , right-click on My Computer, and then click Properties.
  • Under System, you can view the system type.

If your computer is running Windows XP, do the following:

  • Click Start.
  • Right-click My Computer, and then click Properties.
    • If you don’t see “x64 Edition” listed, then you’re running the 32-bit version of Windows XP.
    • If “x64 Edition” is listed under System, you’re running the 64-bit version of Windows XP

Which version of Windows 7 should I install: the 32-bit version or the 64-bit version?
To install a 64-bit version of Windows 7, you need a CPU that’s capable of running a 64-bit version of Windows. The benefits of using a 64-bit operating system are most apparent when you have a large amount of random access memory (RAM) installed on your computer, typically 4 GB of RAM or more. In such cases, because a 64-bit operating system can handle large amounts of memory more efficiently than a 32-bit operating system, a 64-bit system can be more responsive when running several programs at the same time and switching between them frequently.

Normalization in Sql

Normalization is the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one table) and ensuring data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored. There are several benefits for using Normalization in Database.
Benefits

  • Eliminate data redundancy
  • Improve performance
  • Query optimization
  • Faster update due to less number of columns in one table
  • Index improvement

The Normal Forms

The database community has developed a series of guidelines for ensuring that databases are normalized. These are referred to as normal forms and are numbered from one (the lowest form of normalization, referred to as first normal form or 1NF) through five (fifth normal form or 5NF). In practical applications, you’ll often see 1NF, 2NF, and 3NF along with the occasional 4NF. Fifth normal form is very rarely seen and won’t be discussed in this article.

First Normal Form (1NF)

First normal form (1NF) sets the very basic rules for an organized database:

  • Eliminate duplicative columns from the same table
  • Create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key).

First Normal Form
Figure 1: First Normal Form(1NF)

Second Normal Form (2NF)

Second normal form (2NF) further addresses the concept of removing duplicative data:

  • Meet all the requirements of the first normal form.
  • Remove subsets of data that apply to multiple rows of a table and place them in separate tables.
  • Create relationships between these new tables and their predecessors through the use of foreign keys.

Second Normal Form
Figure 2: Second Normal Form(2NF)

Third Normal Form (3NF)

Third normal form (3NF) goes one large step further:

  • Meet all the requirements of the second normal form.
  • Remove columns that are not dependent upon the primary key.

Fourth Normal Form (4NF)

Fourth normal form (4NF) has one additional requirement:

  • Meet all the requirements of the third normal form.
  • A relation is in 4NF if it has no multi-valued dependencies. i.e. If PK is composed of multiple columns then all non-key attributes should be derived from FULL PK only. If some non-key attribute can be derived from partial PK then remove it.

The 4NF also known as BCNF NF.

Fourth Normal Form
Figure 3: Fourth Normal Form(4NF)

Summary

Your data model design is both an art and a science. Balance what works best to support the application that will use the database and to store data in an efficient and structured manner. For transaction-based systems, a highly normalized database design is the way to go; it ensures consistent data throughout the entire database and that it is performing well. For reporting-based systems, a less normalized database is usually the best approach. You will eliminate the need to join a lot of tables and queries will be faster. Plus, the database will be much more user friendly for ad hoc reporting needs.

Select distinct record from datatable, vb.net

Recently i shared my ideas on How to merge and sort two datatables. Completition of this task raise an another issue to Select distinct record from the merged datatable. I found many lengthy process but these are not ok. After some goggling i found a very easy process. Just create a dataview object of the datatable and

dt = dt.DefaultView.ToTable(true, param)

Where param will hold the Column Name for which you want to make distinct values.
So there is no need for any change in How to merge and sort two datatables process, we will just update the code on return statement of the function.

Private Function MergeAndSortTables(ByVal Table1 As DataTable, ByVal Table2 As DataTable, ByVal SortBy As String) As DataTable
  Table1.Merge(Table2)
  Dim View As DataView = Table1.DefaultView
  View.Sort = SortBy

  Return View.ToTable(true)
End Function

It’s funny….

How to merge & sort two datatables

There is two datatables with same column & would like to append one of these datatables on to the end of the other. You may use following code :

Private Function MergeAndSortTables(ByVal Table1 As DataTable, ByVal Table2 As DataTable, ByVal SortBy As String) As DataTable
  Table1.Merge(Table2)
  Dim View As DataView = Table1.DefaultView
  View.Sort = SortBy

  Return View.ToTable()
End Function

How to display Indian rupee symbol in web pages using HTML

Even though Government of India suggested the symbol for Indian rupee and Unicode consortium approved the code for it, it is still not available in all the computers. Official Indian currency symbol was added to Unicode at the unicode version 6.0 during October 2010.
The code approved by Unicode consortium for Indian rupee symbol is: U+20B9
Once all the computers and mobile phones in the world update to latest version of Unicode, everyone will be able to use Indian rupee symbol just like $ or € symbols. Until all computers in the world get updated with unicode 6.0, we will be left with few options to type, display and print Indian rupee symbol in HTML web pages.
If the computer supports Unicode 6.0, then Indian rupee symbol can be displayed in the webpage using the HTML code:
Since Unicode 6.0 is not available in the computers everywhere, you will need to use custom tools and scripts to display them.
Using a font to display the rupee symbol will not normally work on HTML pages since the same font is required on the client machines also to display the rupee symbol on the readers web browser.
Some of the options to display the rupee symbol in web pages are as follows :
A. Using Stylesheet from webrupee.com
webrupee.com has provided a CSS styleseet which you can load from any webpages to display rupee symbol in your webpages. To use rupee symbol, follow the below steps:
1. Include the stylesheet with href : http://cdn.webrupee.com/font

<link rel="stylesheet" type="text/css" href="http://cdn.webrupee.com/font">

2. Just adding the above stylesheet reference in the webpage will not display rupee symbol automatically anywhere. In order to show the rupee symbol, you have to use the SPAN tag with class WebRupee in each place you want to display the symbol.Wherever the SPAN tag is used with the “Rs” enclosed within it, it will automatically display the rupee symbol instead of the text “Rs”.

<span class="WebRupee">Rs</span>
 

B. Display the Rs sign in web pages using Javascript from WebRupee
If you don’t want to type the above code everywhere, you may use the Javascript from WebRupee. If you add the below script reference in the HEAD area of your webpage, all uses of “Rs.” or “Rs” will be converted to Indian rupee symbol.

<script src="http://cdn.webrupee.com/js" type="text/javascript"></script>

ACID (Atomicity, Consistency, Integrity, Durability) in SQL Server

ACID (an acronym for Atomicity Consistency Isolation Durability) is a concept that every database management system must strive to achieve. For a reliable database all these four attributes should be achieved.

Atomicity: stats that database modifications must follow an “all or nothing” rule. Each transaction is said to be “atomic”. If one part of the transaction fails, the entire transaction fails.

Consistency: stats that a transaction either creates a new and valid state of data, or, if any failure occurs, returns all data to its previous state. It means a transaction will never leave your database in a half finished state.

Integrity: keeps transaction separated each other until they are finished. A transaction in process and yet not committed must remain isolated from any other transaction.

Durability: ensures that any transaction committed to the database will not be lost. Committed data are saved by the system in such a way that, even in the event of failure or system restart, the data is available in its correct state.

Assembly in Asp.Net

An assembly is a logical unit of code. It physically exists as DLLs or EXEs. One assembly can contain one or more files like image files, text files etc. along with DLLs or EXEs.
Assemblies in the .Net platform are a solution to a problem that has been around as long as libraries. The problem knows as “DLL Hell”, can be caused by one application overwriting a shared library of another application, usually with a different version.
Imagine you write an application with a shared library and then years later create a new application with an updated library. In order not to break old programs, what do you do with the new library? You could give it a different name, store it in a different location, or overwrite the old ones?
.Net assemblies overcome these issues by storing information about themselves, rather than having that information stored in central location (i.e. system registry). This information is called as Assembly Manifest.
Assembly manifest

  • Assembly manifest is a data structure which stores information about an assembly.
  • This information is stored within the assembly file itself.
  • The information includes version information, list of constituent files etc.

What is in the Assembly?
The assembly contains the intermediate code, resources, and the metadata for itself. We can have a look inside the assembly using the ildasm (Intermediate Language Disassembler) tool that comes as part of Visual Studio. To access it you need to open the Visual Studio Command Prompt and type ildasm.exe. To open the Visual Studio Command Prompt goes to:
Start>All Program>Microsoft Visual Studio 2010>Visual Studio Tools>Visual Studio Command Prompt (2010)

Visual Studio Command Prompt
Figure 1: Visual Studio Command Prompt

This will launch a window application that you can use to explore any .Net application. Once launched, you can open any .Net application (File>Open) and view information within the file, including the manifest, types, classes, namespaces, methods and source code.
Visual Studio Command Prompt
Figure 2: Intermediate Language Disassembler

Assembly Types
You can create two types of ASP.Net Assemblies: Private Assemblies and Shared Assemblies.
The assembly which is used only by a single application is called as private assembly. Suppose you created a DLL which encapsulates your business logic. This DLL will be used by your client application only and not by any other application. In order to run the application properly your DLL must reside in the same folder in which the client application is installed. Thus the assembly is private to your application.
Suppose that you are creating a general purpose DLL which provides functionality which will be used by variety of applications. Now instead of each client application having its own copy of DLL you can place the DLL in ‘Global Assembly Cache’. Such assemblies are called shared assemblies.
Creating a Shared Assembly
The procedure for creating a shared assembly is the same as for a private assembly, except that there are a few extra steps involved before you can use it. All shared assemblies need to be strongly named before they can be installed into the global assembly cache. Strongly named assemblies ensure that the assembly has unique manifest consisting of versioning information and public key.
Steps to create shared assemblies:

  • Create your DLL source code.
  • Generate unique assembly name using SN utility.
  • Sign your DLL with the private key by modifying AssemblyInfo file.
  • Compile your DLL.
  • Place the resultant DLL in global assembly cache using GACUtil utility.

What is Global Assembly Cache?
Global Assembly Cache is nothing but a special disk folder where all the shared assemblies will be kept. It is located under :\WinNT\Assembly Folder.
If you are using .Net framework 4.0 then the folder will be : :\WinNT\Microsoft.Net\Assembly.
How do I create unique assembly name?
Microsoft now uses a public-private key pair to uniquely identify an assembly. To generate this cryptographic key pair, use the SN Tool. Go to Visual studio command prompt and use the following syntax to generate a key file.

sn -k “[DriveLetter]:\[DirectoryToPlaceKeyFile]\[KeyFileName].snk”
e.g. sn -k “C:\GACKey\GACkey.snk”

How do I sign my Assembly?
A key is generated, but it is not yet associated with the assembly of the project. To create this association, double-click the AssemblyInfo.vb file in Visual Studio .NET Solution Explorer. This file has the list of assembly attributes that are included by default when a project is created in Visual Studio .NET.
Modify the AssemblyInfo.vb by adding the following AssemblyKeyFile attribute:

[Assembly: AssemblyKeyFile(“C:\\GACKey\\GACKey.snk”)]

How do I place the assembly in shared cache?
You can install the .dll file by using the Gacutil tool or by dragging the .dll file to the appropriate folder. If you use the Gacutil tool, you can use a command that resembles the following:

gacutil -I “[DriveLetter]:\[DirectoryOfDllFile]\[dll File]”

To drag the file, open two instances of Windows Explorer. In one instance, find the location of the .dll file output for your console project. In the other instance, find WinNT\Assembly. Then, drag your .dll file to the Assembly folder.
Hands On…
Now, that we have understood the basics of assemblies let us apply our knowledge by developing a simple shared assembly.
In this example we will create a VB.NET component called SharedAssembly. We will also create a key file named sample.snk. We will sign our component with this key file and place it in Global Assembly Cache.
Step 1: Creating our sample component
Here is the code for the component. It just includes one method which returns a string “Hello World”.

Namespace SharedAssembly
  Public Class Test
    Public Function Helloworld() As String
      Return “Hello World”
    End Function
  End Class
End Namespace

Visual Studio Command Prompt
Figure 3: VB.Net Class File

Step 2: Generate a key file
To generate the key file use the following command at visual studio command prompt:

SN –k c:\sample.snk

Visual Studio Command Prompt
Figure 4 : Generate Key File

Step 3: Sign your component with the key file
To sign the component add the following AssemblyKeyFile attribute in AssemblyInfo.vb file:

[Assembly: AssemblyKeyFile(“C:\\sample.snk”)]

Visual Studio Command Prompt
Figue 5 : AssemblyInfo.vb

Step 4: Host the signed assembly in Global Assembly Cache
To install the assembly in Global Assembly Cache we will use GACUtil Tool. Go to Visual studio command prompt, use the following code :

gacutil –i D:\Test\sikarnarender.com\Assembly\SharedAssembly
\SharedAssembly\bin\Debug\SharedAssembly.dll

Visual Studio Command Prompt
Figure 6: GACUtil.exe

After hosting the assembly just goes to WINNT\Assembly folder and you will find your assembly listed there.

State Management with Context.Items, Asp.net

Passing values between pages is a common task in every asp.net web application.There are many options for state management including Session, Cookies, QueryString etc. Each of these have their strength and weakness and each is designed for different circumstances, it just depends of your requirement. This article will focus on the use of context.items collection to pass variable between different pages.

Assume we have a ecommerce site, the page “ProductList” shows the list of products.When I click on a product, it will redirect the user to “ProductDescription”. How do I tell “ProductDescription” which product to show ?

One possible approach is to use the QueryString and pass the ProductId to the “ProductDescription” page as shown in listing 1 and 2.

Response.Redirect(“ProductDescription.aspx?PrdId=2”)

Listing 1: “ProductList” using the QueryString

Dim PrdId as Integer=Request.QueryString(“PrdId”)

Listing 2: “ProductDescription” using the QueryString

The above approach is totally acceptable. There are several disadvantages of this approach, some of which are as follows:

  • The QueryString is exposed with the URL meaning sensitive data may be revealed.
  • The length of the QueryString is generally limited (e.g. 256 bytes in IE).
  • The QueryString can only contain character data (no objects).
  • Response.Redirect requires a round trip from server to client to server.

A better approach is to store the Product Id in Context.Items collection, then use server.transfer to redirect to the “ProductDescription” as shown in listing 3 and 4.

Context.Items.Add(“PrdId”,2)
Server.Transfer(“ProductDescription.aspx”)

Listing 3: “ProductList” using the Context.Items collection

Dim PrdId as Integer=Context.Items.Item(“PrdId”)

Listing 4: “ProductDescription” using the Context.Items collection

Server.Transfer performs a server-side redirect that is transparent to the user, meaning there is no need of a round trip.The Context.Items collection is also capable of storing objects instead of just plain character data.

It is important to keep in mind that values stored in the Context.Items collection only last for the current request. If I were to do a postback on the “ProductDescription” page, the Context item “Id” would be lost. Most of the time this is convienient since we only need to store that value between pages and no longer.

Viewstate collection is the solution to retain the values between postbacks.

Turn on Internet connection sharing” option missing,Windows 7

 

This is a crazy bug and the main reason for this blog. The first time you enable internet connection sharing on an ad hoc connection, everything should be fine. And then… this option disappears. Impossible to find it. Impossible to share your internet connection again and without internet connection sharing, your ad hoc network looks useless.

 

Why this bug ?

 

Basically, you can only share your internet connection sharing once. That means it is linked to the first ad hoc network you have created and won’t be available unless you remove your first-in-you-life-created ad hoc network. The problem ? This ad hoc network is not shown anywhere ! Thank you Microsoft ! Basically you need to remove something that is not shown anywhere and that you cannot manage. Restarting your PC, looking wherever you want won’t help either. When Microsoft does something bad it does it really bad.

 

The solution ?

 

Well, there is a lot of “solutions” on the net but none worked for me. I found my method and wanted to share it (reason for this whole blog).

 

1.Go to your network settings: “Control Panel” / “Network and Sharing Center” and click on the wonderfully called “Change adapter settings” (why windows cannot just call it “Manage internet connections” is beyond me)

 

2.You should see 2 important connections here:

 

– your local connection (the one that enables you to connect to the internet). It is probably in state “Network, Shared”.

 

– your wireless connection (the one you will be using to give internet access to your other devices.

 

– you may have plenty of other connections that are not important.

 

– you will NOT have ad hoc connections (that would be too good to be true).

 

3.Right click on your local connection and go to Properties. There should be a tab called “Sharing” which is probably activated. Disable it (uncheck the first option “Allow other…”).

 

4.Disable your wireless connection.

 

5.Re-enable your wireless connection. As you have unchecked the sharing, when your wireless connection is re-enabled it should not use the internet-sharing-unique-slot.

 

6.Simply retry to create an ad-hoc connection. The option “Turn on Internet connection sharing” should now appear correctly.

Table Variables in Sql Server 2005

 

Table variable is almost similar to the temporary table in sql server 2005. Table variables are replacement to temporary tables. The following syntax shows how to define a table variable.

 
Declare @Customer table ( CustomerID int identity(1,1), CustomerName varchar(100), CompanyName varchar(100), Address varchar(250) )
 

You can notice the syntax to define a table variable is similar to the syntax to normal table definition. declare keyword is used in place of create keyword. And table name is prefixed with ‘@’ as all tsql variables do.

 

1.Table variables are stored in memory rather than in database.

 

2.Querying table variables is very fast as there are no disk reads needed.

 

3.The scope the table variables is same as other tsql variables. i.e, within statements batch or sproc

 

4.Table variables cannot be dropped as they are automatically disappeared when they reach out scope

 

5.As explained above all the data in table variables is stored in server’s memory. So if there is huge data then it is not recommended to use table variables to avoid memory overhead.

 

6.If the number of records is more than 100 then it is recommended to use temporary tables.To learn more about temporary tables please read this blog post : http://sikarnarender.blogspot.com/2011/11/how-to-create-temporary-table-in-sql.html