Installing SQL SERVER 2005 and SQL REPORTING SERVICES

December 15, 2007

Installing SQL SERVER 2005 and Installing SQL REPORTING SERVICES:

1.       First we need to create service account for Sql Server and Reporting Services. Lets create a service account named SqlReportServer.

A.      Start  –> Settings –> Control Panel –> Administrative Tools

B.      Click Computer Management

C.      Expand the Local Users And Groups

D.      Right-click the Users folder and select New User.

E.       Enter a User name – SqlReportServer

F.       Enter description – Account for SQL Server and Reporting Services.

G.     Enter Password.

H.      Enter Confirm password.

I.        Uncheck “User must change password at next logon” check box.

J.        Select “User cannot change password” check box.

K.      Select “Password never expires” check box.

L.       Click “Create” button.

2.       Now we will install SQL SERVER 2005 and SQL REPORTING SERVICES. For this first insert SQL SERVER CD wait for auto run to open.

3.       Under install click “Server components, tools, Books Online, and samples”.

4.       You will then asked to accept “End User License Agreement”, Click check box “I accept the licensing terms and conditions.” and then click “Next”.

5.       It will then ask you to install prerequisites and then click “Install”.

6.       It will install prerequisites and then click next.

7.       Screen will show that system is inspecting configuration. Click  “Next”

8.       It will show SQL SERVER INSTALIZARD click “Next”.

9.       Another in-depth configuration screen will appear and if there is any error you need to repair otherwise click “Next”.

10.   Next on the Registration Information page, type a Name and, optionally, a Company name, and then click next.

11.   Now on this screen we will need to select components we want to install.

12.   Click the check box next to SQL Server Database Services†, Analysis Services†, Reporting Services† and then click the check box next to Workstation Components, Books Online And Development Tools. († in future tutorials we will learn SQL DBA Tips and Reporting Services and Analysis services so we install it together)

13.   Click Advanced

14.   Click next to Documentation, Samples, And Sample Databases, click the arrow next to Sample Databases, and select Entire Feature Will Be Installed on Local Hard Drive. Click the arrow next to Sample Code and Applications, and select Entire Feature Will Be Installed on Local Hard Drive. Now click “Next”.

15.   On the Instance Name screen select “Default Instance” and click “Next”.

16.   On the Service Account screen, click “Use a domain user account” and enter account information we have created in step 1(account name SqlReportServer ) when finished click “Next”.

17.   On the Authentication Mode screen select “Mixed Mode” enter a password for sa account and then click “Next”.

18.   On next screen select “Latin1_General” collation designator and sort order.

19.   On the Report Server Installation Options screen select “Install but do not configure the server” click “Next”.

20.   On the Error and Usage Report Settings page, you can choose to send reports to Microsoft. Click “Next”,

21.    Now it will show you the list of components will be installed then click “Install”.

22.   Now Setup progress screen appears during install.  Once setup finished for all components click “Next”.

23.   You can review Summary log for any setup issue on completing sql server setup screen.  Click “Finish” to complete installation.

      24.   Reboot your system if required.
           
Once you finish installation install “SQL Server 2005 Service Pack 2”.
                http://technet.microsoft.com/en-us/sqlserver/bb426877.aspx
             For more reading please check:
             http://support.microsoft.com/kb/934164(How to install SQL Server 2005 Reporting Services on a Windows Vista)


-         
Harpreet Virk

(Pilibangan)


Turning Off Client-Side Validation

December 8, 2007


Each of the validation server controls has a property called EnableClientScript. This property is set to True by default, but setting it to False prevents the control from sending out a JavaScript function for validation on the client.


1.       Disabling client-side validations in a validation control

<form id=”form1″ runat=”server”>
<div>
<asp:TextBox ID=”txtName” runat=”server”></asp:TextBox>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ Runat=”server” ErrorMessage=”Required!!!” ControlToValidate=”txtName” EnableClientScript=”false”></asp:RequiredFieldValidator>
</div>   
</form>

2.       Reamove client-side capability programmatically

protected void Page_Load(object sender, EventArgs e)
{
 RequiredFieldValidator1.EnableClientScript = false;
}


3.    Disable client-side script capabilities for all the validation controls on a page from within the Page_Load event.
 


protected
void Page_Load(Object sender, EventArgs e)
{
foreach (BaseValidator bv in Page.Validators)
{
 bv.EnableClientScript = false;
}
}

-          Harpreet Virk 
        Pilibangan


Insert (inject) client script into page in ASP.NET 2.0

November 28, 2007

Insert  (add) javaScript to code behind page as RegisterClientScriptBlock in ASP.NET 2.0

Some time we need to implement client-side functionality to page. To add that client-side functionality to page we need to add (insert) JavaScript (client-side script) into page.

For example if some user is ideal for certain time of period we should pop-up an alert window asking if user would like to continue.

You can insert strings of client side script into application or in some cases you can have separate file (include file). We will discuss both scenarios in our example.

The parameters of RegisterClientScriptBlock are:

1.       Type: The type of calling page.

2.       Key: The key to identify the script.

3.       Script: Content of the script to be sent to the client side.

4.       AddScript: Indicate whether the script should be enclosed within a <script> bloc.

Main.aspx -

<body>   
<form id=”form1″ runat=”server”>
    <div>       
      
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”Call Client Script” />
    </
div>
   
</form>
</body>

Main.aspx.cs

public partial class Main: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{  
if (!Page.IsPostBack)
    
{
       
string script = “<script> alert(‘current date and time is: “ + DateTime.Now + “‘)</script>”;
       this.Page.ClientScript.RegisterClientScriptBlock(typeof(Page), “MyKey”, script);     
}
  
}
// using external client-side file  
protected void Button1_Click(object sender, EventArgs e)
   
{
    
string scriptUrl = “include.js”;
this.Page.ClientScript.RegisterClientScriptInclude(typeof(Page), “MyKey”, scriptUrl);
}
}

Include.js
alert(“Hello from Javascript”);

When converting from .net 1.1 to 2.0 you get following warning:

‘System.Web.UI.Page.RegisterClientScriptBlock(string, string)’ is obsolete: ‘The recommended alternative is ClientScript.RegisterClientScriptBlock(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202

To resolve this issue use

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), “MyKey”, script);

-          Harpreet Virk 


Working with Array in ASP.NET (C#)

November 10, 2007

Today we will discuss about One-Dimensional Arrays and and how we can use arrays with ASP.NET.  Arrays are basically lists of sequentially accessible data. They provide a means of accessing and storing data in a way that allows multiple related elements to be manipulated via numeric index.

SampleArray.aspx

<form id=”form1″ runat=”server”>
<
div>
<
asp:Label ID=”Label1″ runat=”server” Width=”306px”></asp:Label><br />
<
asp:DropDownList ID=”DropDownList1″ runat=”server” Width=”306px”>
</
asp:DropDownList><br />
<
asp:DropDownList ID=”DropDownList2″ runat=”server” Width=”306px”>
</
asp:DropDownList> <br />
<
asp:Label ID=”Label2″ runat=”server” Width=”306px”></asp:Label><br />
<
asp:DropDownList ID=”DropDownList3″ runat=”server” Width=”306px”>
</
asp:DropDownList><br />
<
asp:Label ID=”Label3″ runat=”server” Width=”306px”></asp:Label><br />
<
asp:Label ID=”Label4″ runat=”server” Width=”306px”></asp:Label></div></form>
 

SampleArray.aspx.cs

namespace WebApplication1
{
public partial class SampleArray : System.Web.UI.Page
{
//Declaring and Initializing Arrays
static private string[] names = new string[6] { “Paul”, “Harpreet”, “John”, “Andy”, “Jeff”, “Mike” };
static private string[] productNames = {
“Blue Shirt”, “Red Shirt”, “Blue Pent”, “Red Pent” };
protected void Page_Load(object sender, EventArgs e)
{
foreach (string name in names)

{
//Show array items on lable
Label1.Text += (name) + “<br>”;
//populate Dropdownlist with array
DropDownList1.Items.Add(name);
}
//Sort array reversely
Array.Reverse(names);
foreach (string strReverseArray in names)
{
DropDownList2.Items.Add(strReverseArray);
}
// Find array element by array index
Label2.Text = names.GetValue(3).ToString();
//Sort the array
Array.Sort(names);
foreach (string strSort in names)
{
DropDownList3.Items.Add(strSort);
}
//Pass array as a parameter
showNames(names);
//use FindAll to search element
string[] blueProducts = Array.FindAll(productNames, IsBlueProduct);
foreach (string product in blueProducts)
{
Label4.Text += (product) +
“<br>”;
}
}
 private void showNames(string[] names)
{
int counter = 1;
foreach (string personName in names)
{
Label3.Text += counter+“. “+ (personName) + “<br>”;
}
counter++;
}
static bool IsBlueProduct(string productName)
{
if (productName.ToUpper().Contains(“BLUE”))
return true;
else
return false;
}
}
}
-    Harpreet Virk


How to access control’s value to another page (Pass Values between Web Pages in ASP.NET 2.0)

October 30, 2007


PostBack to another page in ASP.net 2.0 You can use PostBackUrl attribute of Button control of source page to post to another page. 

FirstPage.aspx:

<form id=”form1″ runat=”server”>
    <div>
<asp:Label ID=”Label1″ runat=”server” Text=”First Page” Width=”305px” ForeColor=”Navy”></asp:Label>
<
br />
<br />
<asp:Label ID=”Label2″ runat=”server” Text=”First Name” Width=”149px”></asp:Label>
<asp:TextBox ID=”txtFirstName” runat=”server”></asp:TextBox>
<br />
<asp:Label ID=”Label3″ runat=”server” Text=”Last Name” Width=”149px”></asp:Label>
<asp:TextBox ID=”txtLastName” runat=”server”></asp:TextBox>
<br /><br />                                     
<asp:Button ID=”BtnSubmit” runat=”server” PostBackUrl=”~/SecondPage.aspx” Text=”Go To Second Page” /></div></form>

SecondPage.aspx:

<form id=”form1″ runat=”server”>
<div>
<asp:Label ID=”Label1″ runat=”server” Text=”Second Page” Width=”305px” ForeColor=”Navy”></asp:Label>
  <br />
 <br />
<asp:Label ID=”Label2″ runat=”server” Text=”First Name” Width=”149px”></asp:Label>
<asp:Label ID=”LblFirstName” runat=”server” ForeColor=”#C00000″ Width=”157px”></asp:Label>
 <br />
<asp:Label ID=”Label4″ runat=”server” Text=”Last Name” Width=”149px”></asp:Label>
<asp:Label ID=”LblLastName” runat=”server” Text=”LblLastName” ForeColor=”#C00000″ Width=”155px”></asp:Label>
</
div>
</form>

SecondPage.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{   
// First we get a reference to the source page by
  
//using the target page’s PreviousPage property,
   
//this PreviousPage property holds the posted page.
   
//Now we check if this property(PreviousPage)is null or not.
if (Page.PreviousPage != null)
{    
// Now we call the FindControl method to get the control
TextBox FirstNameTextBox =
(TextBox)Page.PreviousPage.FindControl(“txtFirstName”);
TextBox LastNameTextBox =
(TextBox)Page.PreviousPage.FindControl(“txtLastName”);
// If it is not null then show the result.
if (FirstNameTextBox != null)
{        
LblFirstName.Text = FirstNameTextBox.Text;
 
}
        
if (LastNameTextBox != null)
      
{
        
LblLastName.Text = LastNameTextBox.Text;
      
}
   
}
 
}
For more detail reading please check:

http://msdn2.microsoft.com/en-us/library/6c3yckfw.asp

- Harpreet Virk


List Controls in ASP.NET 2.0

October 30, 2007

List Controls in ASP.NET 2.0
 
All the list controls inherit from the System.Web.UI.WebControls.ListControl class.  Following are the ListControl Class Properties: 1.  AutoPostBack: If AutoPostBack is true, the form is automatically posted back when the user changes the current selection.
2.  DataSource: Specify the data source for the items.
3.  DataMember: The DataMember property is used to identify the table user want to use.
4.  DataTextField: Indicates the field from data source to use for option text.
5.  DataValueField: Indicates the field from data source to use for option Value.
6.  DataTextFormatString: Gets or sets the formatting string used to control how data bound to the list control is displayed.
7.  Items: Returns a collection of ListItem items.
8.  SelectedIndex: Returns or sets the index of the selected item.
9.  SelectedItem: Returns a ListItem that represent the currently selected Item  List Controls: 

  1. BulletedList: BulletedList controls display list of items with a variety of bullet styles. User can also use this control to create a list of hyperlinks.BulletStyle property can be used to decide what type of style is needed. It can be Numbered (1, 2, 3…), LowerAlpha (a, b, c…) and UpperAlpha (A, B, C…), LowerRoman (i, ii, iii…) and UpperRoman (I, II, III…), and the bullet symbols Disc, Circle, Square.
  2. CheckBoxList: Represents a list of check boxes. Each list item in a CheckBoxList represents an individual check box.
  3. DropDownList: Allows the user to select a single item from a drop-down list.
  4. ListBox: Displays a list of items from which user can make a selection.
  5. RadioButtonList: The items are rendered as radio buttons.

 Code:ListControl.aspx.cs  
protected void Page_Load(object sender, EventArgs e)       
    
{     
           
       
ArrayList aryColor = new ArrayList();
            
       
if (!Page.IsPostBack)
           
          
{
               
            
aryColor.Add(“Red”);
          
  aryColor.Add(“Black”);
          
  aryColor.Add(“White”);
          
  aryColor.Add(“Blue”);

            //CheckBoxList
        
    ChklColor.DataSource = aryColor;
        
    ChklColor.DataBind();
        
    //DropDownList     
            
DdlColor.DataSource = aryColor;
 
            
DdlColor.DataBind();
            
            
//ListBox
            
            
LbColor.DataSource = aryColor;
          
  LbColor.DataBind();           
            
//RadioButtonList
             
            
RblColor.DataSource = aryColor;
          
  RblColor.DataBind(); 
            
//BulletedList
   
            
BlColor.DataSource = aryColor;
          
  BlColor.DataBind();
         }     
    
}
 
Code:ListControl.aspx     
<form id=”form1″ runat=”server”>
<asp:CheckBoxList ID=”ChklColor” runat=”server”>
</
asp:CheckBoxList> <br />
<asp:DropDownList ID=”DdlColor” runat=”server”>
</
asp:DropDownList> <br />
<asp:ListBox ID=”LbColor” runat=”server”>
</
asp:ListBox> <br />
 
<asp:RadioButtonList ID=”RblColor” runat=”server”>
</
asp:RadioButtonList> <br />
       
<asp:BulletedList ID=”BlColor” runat=”server” BulletStyle=”Circle”></asp:BulletedList> <br />

<!– Hyperlink BulletedList –>       
<asp:BulletedList ID=”BlHyperlink” DisplayMode=”HyperLink” runat=”server”>  
                        <asp:ListItem Value=”http://www.google.com”>GOOGLE</asp:ListItem>
<asp:ListItem Value=”http://www.asp.net”>ASP.NET</asp:ListItem>
<asp:ListItem Value=”http://msdn.microsoft.com”>MSDN</asp:ListItem>
</asp:BulletedList>

 </form>

- Harpreet virk