6 July 2012

SQL SERVER 2008 Installation Step By Step

A Step by Step guide to installing SQL Server 2008 simply and successfully with no prior knowledge
Developers and system administrators will find this installation guide useful, as will seasoned DBAs. It will teach you the basics required for a typical, problem-free installation of SQL Server 2008, allowing you to add other components later if you wish.
Remember to install the .Net Framework 3.5
Before you start the installation, you’ll need to install the .Net 3.5 Framework. This comes pre-installed on Windows 2008 Server, but for earlier versions of Windows, you’ll need to install it first. This is a straightforward pre-requisite and is usually included as part of the SQL Server 2008 installation. However, if you don’t know how to do this, or for some reason you need to download it, check out the guide Installing .Net Framework 3.5 for SQL Server 2008.
Once this Framework in installed you can commence the installation of SQL Server 2008.
STEP 1 : Copy the installation files
First off I’d recommend you copy the entire directory structure from the SQL Server 2008 installation disc to the C: drive of the machine you are going to install it on.
Although this means you need to grab a cup of coffee whilst it’s copying, this has three advantages:
  • It makes the installation process much faster than running it from CD/DVD once it gets started.
  • It allows you to easily add or remove components later, without having to hunt around for the CD/DVD.
  • If your media is damaged and a file won’t copy, you get to find out now, rather than halfway through the installation.
Here’s what my system looks like after the copy:
STEP 2 : Setup.exe
Double click on the setup.exe file.
After a few seconds a dialog box appears:

This will disappear from the screen and then the main installation page appears:

STEP 3 : SQL Server Installation Center
Click on the Installation hyperlink on the left hand side of the screen:
STEP 4 : SQL Server Installation Center
Click on the "New Server stand-alone installation" link on the right side of the screen:

The following dialog appears on the screen whilst the install program prepares for installation:

After a minute or so (the timing will vary according to your system), the following screen appears:

STEP 5 (optional) :
If any checks have failed, click on the Show details button or "View detailed report link" to find out the cause, correct it, then click on the Re-run button to perform the checks again.
STEP 6 : Product key
If all checks have passed, click on the OK button. After a few moments, the option to select the edition and to enter the license key (or “product key”) will appear. Note that the product key box may already be populated, depending on which edition you have. Don’t enter the product key we’ve shown here, it won’t work on your system!:
STEP 7 : License Terms
Enter the product key into the box, or choose the free edition if you're evaluating SQL Server 2008, and click on the Next button:
Click in the "I accept the license terms" check box, then click on the Next button again.
STEP 8 : Setup Support Files
The following screen appears; click on the Install button:
The following screen will appear whilst Windows Installer prepares itself for the installation. This will take a short while:
After 30 seconds or so the dialog appears again:

STEP 9 : Setup Support Rules
If all is well, the following screen appears:
Click on the Next button again.
STEP 10 : Feature Selection
Select the features you want to install.
At a minimum, the following are useful (I'd argue essential), but what you need will depend on your needs:
Click on the Next button.
STEP 11 : Instance Configuration
After a short while the following screen appears:
For most installations, keep the default settings.
Click on the Next button.
STEP 12 : Disk Space Requirements
This screen just tells you if you have sufficient disk space on the drive you’re installing to, and what’s going to be installed where.
Click on Next

STEP 13 : Server Configuration
This step allows you to set up the service accounts that will be used to run SQL Server. If you have created Windows NT or Active Directory accounts for use with services, use these.
If not, then just to get the installation up and working, use the built-in Network Service account for all three services listed (this account does not require a password).
This allows SQL Server to start up after installation. However, it can be easily changed later to another account through the Services applet (Control Panel -> Administrator Tools -> Services):
In addition, remember to change the Startup Type to Automatic, for all three services. This automatically starts the SQL Server database engine, SQL Agent and SQL Browser services when the server is re-booted.
The first service runs the SQL Server database engines executable process. The other two services allow scheduled jobs to run after installation (and after a re-boot), and allow the SQL Server to be found by clients on the network.
Do not worry about changing the collation tab, unless there is a specific requirement for anything other than the default collation sequence. Finally, click on Next.
STEP 14 : Database Engine Configuration – Account Provision
This screen allows you to set up database engine security.
Change the Authentication Mode to Mixed Mode unless you are certain you only need Windows-only authentication.
  • Many third party applications rely on SQL Server logins to operate correctly, so if you are setting up a server for a third party application, rather than one developed in-house, enabling Mixed Mode authentication is a good idea.
If you pick Mixed Mode security, you must also enter a password for the sysadmin account (sa).
Enter and confirm a secure password for the sa account and keep it somewhere safe. Do not give it to any one you do not want to have access to the SQL Server.
Note that you MUST also provide a Windows NT account on the local machine as a SQL Server administrator. If you do not want Windows system administrators to be able walk up to the box and login to SQL Server, create a new, local, dummy Windows user and add this account instead. Otherwise, add in the local administrator account, or your own Windows account on the domain in which the SQL Server will reside.
STEP 15 : Database Engine Configuration – Data Directories
Click on the Data Directories tab.
Change the directories to specify which drives in your system will be used for the various types of database files.
Generally it’s advisable to put the User database directory and User log directory on separate physical drives for performance, but it will depend on how Windows has been configured and how many disk drives you have available.
If you are installing on a single drive laptop or desktop, then simply specify:
Data root directoryC:\Program Files\Microsoft SQL Server
User database directoryC:\Data
User log directoryC:\Logs
Temp DB directoryC:\TempDB
Temp Log directoryC:\TempDB
Backup directoryC:\Backups
Do not click on the FILESTREAM tab unless you know you need to change these options, as it is not generally required for most installations, but can easily be changed by using sp_configure 'filestream_access_level', ''after SQL Server has been installed. Click on Next.
STEP 16 : Error Usage Reporting
This screen simply asks if you want to send error information to Microsoft and can safely be skipped if you do not want to share any information.
Click boxes if you want to help Microsoft help you.
Click on Next again…
STEP 16 : Installation Rules
This screen simply checks if there are any processes or other installations running which will stop the installation of SQL Server 2008.
Click on Next again – you’re almost ready to install:
STEP 17 : Ready to Install
This screen summarises what you are about to install and gives you a last chance to cancel or change anything that’s wrongly configured:

Check that what’s being installed is what you want and then click on Install when you’re sure you want to start the installation process:
Installation Progress
SQL Server 2008 will now install. How long it takes depends on the speed of your machine, what load it’s under, the installation media (CD is slower) and what you’ve chosen to install.

…More Installation Progress
... and Finally
Finally, the installation will complete:
...and the following dialog box will appear:
Click on OK, the machine will NOT reboot.
The following will appear:
…followed by:
Click on the Next button again...
STEP 18 : Installation Complete
The following screen appears:
It may be worth clicking on the installation log at the top of the screen to check everything’s gone as expected. Not that this is MUCH smaller than the usual SQL Server installation log files of old.
Finally, click on the Close button. The following dialog will appear:

Click on OK – your server will NOT re-boot at this point.
The dialog box will disappear and you will be returned to the Installation Center:
Click on the Close button (the “x”) in the top right of the screen.
Finally, manually reboot your machine to complete the SQL Server 2008 installation.
Top Tips :
How to check that SQL Server 2008 has installed correctly
Here are a short number of post-installation checks which are useful to perform after re-booting your new SQL Server. You don’t have to run these, and there are other ways to check, but they are very useful for non-DBAs to be sure that the installation is basically sound and a connection can be made to the new SQL Server before handing it over to someone else.
Check 1: Has the SQL Server Service Started?
Check SQL Server 2008 has started.

Check 2: Does Management Studio Work?
Check Management Studio works by firing it up.

Click on NO when you see this dialog box:

Check 3: Can you run a basic query against the new SQL Server?
Check SQL Server works by running a simple query from Management Studio:

4 July 2012

Repeator Control in Asp.Net

The Repeater control is used to display a repeated list of items that are bound to the control. The Repeater control may be bound to a database table, an XML file, or another list of items. 
Repeater is a Data Bind Control. Data Bind Controls are container controls. Data Binding is the process of creating a link between the data source and the presentation UI to display the data. ASP .Net provides rich and wide variety of controls, which can be bound to the data. Repeater has 5 inline template to format it:

1. <HeaderTemplate>

2. <FooterTemplate>

3. <ItemTemplate> 
4. <AlternatingItemTemplate>
5. <SeperatorTemplate>
6. <AlternatingItemTemplate> 

HeaderTemplate: This template is used for elements that you want to render once before your ItemTemplate section.

FooterTemplate: - This template is used for elements that you want to render once after your ItemTemplate section.

ItemTemplate: This template is used for elements that are rendered once per row of data. It is used to display records

AlternatingItemTemplate: This template is used for elements that are rendered every second row of data. This allows you to alternate background colors. It works on even number of records only.

SeperatorTemplate: It is used for elements to render between each row, such as line breaks.

Some point about Repeater Control
  • It is used to display backend result set. It is used to display multiple tuple.
  • It is an unformatted control. The Repeater control is a basic templated data-bound list. It has no built-in layout or styles, so you must explicitly declare all layout, formatting, and style tags within the control's templates.
  • The Repeater control is the only Web control that allows you to split markup tags across the templates. To create a table using templates, include the begin table tag (<table>) in the HeaderTemplate, a single table row tag (<tr>) in the ItemTemplate, and the end table tag (</table>) in the FooterTemplate.
  • The Repeater control has no built-in selection capabilities or editing support. You can use the ItemCommand event to process control events that are raised from the templates to the control.
We have to use scriptlets for data access.

Data Bind Control can display connected and disconnected model.

Data Bind Control have DataBind() method and DataBound event

-> DataBind()
-> ItemCreated -> Event
-> DataBound -> Event

System.Commom.Data        namespace
-> DBDataRecord               Class

Controls -> Child Control

Every DataBindControl implement collection.

The data in DataSource is bound to Repeater using its DataBind Method. Once the data is bound, the format of each data item is defined by a template like ItemTemplate.

How to use a Repeater Control?

Create a new website with name RepeaterControl

Double click the web.config file and write following code in it:

<connectionStrings>
                <add name="constr" connectionString="initial catalog=puran; data source=MCN002; integrated security=sspi"/>
        </connectionStrings>

Default.aspx file code


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

<!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">    
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" />  
  <title>Repeater Controls in ASP.NET</title>
</head>
<body>    
<form id="form1" runat="server">    
<div>        
<asp:Repeater ID="RepeatInformation" runat="server">            
<HeaderTemplate>               
 <table class="tblcolor">  
<tr>  
<b><td> Roll No</td>                            
<td>Student Name</td>                           
 <td> Total Fees</td>  </b> 
</tr>            
</HeaderTemplate>            
<ItemTemplate>                
<tr class="tblrowcolor">  <td>  <%#DataBinder.Eval(Container,"DataItem.RollNo")%>  </td>                    
<td> <%#DataBinder.Eval(Container,"DataItem.Name")%> </td>                   
 <td><%#DataBinder.Eval(Container,"DataItem.Fees")%> </td>                
</tr>            
</ItemTemplate>            
<SeparatorTemplate>                
<tr> <td>  <hr /> </td>  <td> <hr /> </td> <td><hr /></td></tr>            
</SeparatorTemplate>           
 <AlternatingItemTemplate>                
<tr> <td> <%#DataBinder.Eval(Container,"DataItem.RollNo")%> </td>                    
<td> <%#DataBinder.Eval(Container,"DataItem.Name")%> </td>                    
<td> <%#DataBinder.Eval(Container,"DataItem.Fees")%>  </td>               
 </tr>           
 </AlternatingItemTemplate>           
<SeparatorTemplate>                
<tr> <td><hr /> </td><td>  <hr /> </td><td> <hr /> </td> </tr>            
</SeparatorTemplate>           
 <FooterTemplate>               
<tr> <td>School Records displayed</td></tr> 
</table>            
</FooterTemplate>        
</asp:Repeater>  
  </div>   
 </form>
</body>
</html>

Code behind file code

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page{
    SqlConnection con;
    SqlCommand cmd = new SqlCommand();
    protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
        cmd.Connection = con;
        cmd.CommandText = "select * from student";
        con.Open();
        RepeatInformation.DataSource = cmd.ExecuteReader();
        RepeatInformation.DataBind();
        con.Close();
    }
}

The ASP.NET Repeater Control will not render the result unless you bound it to a data source through its DataSource property. Output of the above program

repeater.gif
This article is for making a beginner learn and use Repeater Control.

Note: In the above example you have to change the connection string according to your database and data source.