3

Install Configure And Troubleshooting Sql Server Reporting Services

In this post i'm explaining how to Install Configure And Troubleshoot Sql Server Reporting Services.

System Requirements

1. Windows Server 2003 / Windows 2000 Server/ Windows vista / Windows XP/ Windows Server 2008
2. IIS 5.0 or later is required for Microsoft SQL Server 2005 Reporting Services (SSRS) installations.
3. ASP.NET 2.0 is required for Reporting Services. When installing Reporting Services, SQL Server Setup will enable ASP.NET if it is not already enabled.
4. SQL server 2005 with SP1(In case you need to reinstall reporting services its advised to reinstall full SQL server rather then just reporting services).
5. SQL Server Setup requires Microsoft Windows Installer 3.1 or later and Microsoft Data Access Components (MDAC) 2.8 SP1 or later. You can download MDAC 2.8 SP1 from this Microsoft Web site.

Installation

Follow the steps mentioned in the link below
http://msdn.microsoft.com/en-us/library/aa545330.aspx

Run the Reporting Services Configuration tool, connect to the report server instance you've installed, and review the status indicator for each setting to verify that it is configured.


Configuring and troubleshooting reporting services

In browser window type http://localhost/reportserver (http://-computer name-/ReportServer-instance name-).
You can also go and try running report server directly through IIS.

First of all , go to start menu > run , type inetmgr to open IIS Manager
Now click on Web sites > Default Web Site > right click on Reports (Your report directory ) [in my case it's Reports$SQLExpress] ,and select properties




In properties window , go to Directory security tab > Authentication and access control > click on Edit



here Check the checkox saying enable anonymous access > copy the User name from the user name box , which should be entered automatically

And Uncheck it Again , don't apply anything for now , i mean don't allow anonymous access

open browser and type http://localhost/ReportServer or whatever is ur report server url , in my case it's http://localhost/ReportServer$SQLExpress,

login by giving username and password

You should see this window having two tabs , Contents , properties


click on properties tab, Now click on new role assignment

In the Group or user name Text box paste the user name u copied from iis manager , assign whatever roles u want to give

only Content Manager role will do as well

Click on Ok to finish this

Now Again open IIS Manager , and go to properties window of your ReportServer directory

Now Check the CheckBox saying allow anonymous access

Click on apply and this will resolve your issues

Good luck

30

Populate Cascading DropDownList On Selection ASP.NET

Populate Cascading DropDownList In Asp.Net C# VB.NET Based On Selection Of Other DropDown In SelectedIndexChanged Event. binding state DropDown based on selection of Country DropDownlist and then populating Cities on selection of State.

There are several situations where we need to populate second or third dropdownlist list based on selection of first or second dropdwonlist in asp.net.

populate dropdown based on selection in SelectedIndexChanged Event asp.net
For this we need to write code in code behind in the SelectedIndexChanged Event of respective Dropdownlist to implement the cascading of DropDowns.

HTML SOURCE OF PAGE
   1:  <form id="form1" runat="server">
   2:  <div>
   3:  <table><tr>
   4:  <td><strong>Country :</strong></td>
   5:  <td><asp:DropDownList ID="ddlCountry" runat="server"
   6:                        AutoPostBack="True" 
   7:                        onselectedindexchanged=
   8:                   "ddlCountry_SelectedIndexChanged">
   9:      </asp:DropDownList>
  10:  </td>
  11:   
  12:  <td><strong>State:</strong></td>
  13:  <td><asp:DropDownList ID="ddlState" runat="server" 
  14:                        AutoPostBack="True" 
  15:                        onselectedindexchanged=
  16:                   "ddlState_SelectedIndexChanged">
  17:      </asp:DropDownList></td>
  18:   
  19:  <td><strong>City:</strong></td>
  20:  <td><asp:DropDownList ID="ddlCity" runat="server" 
  21:                        AutoPostBack="True">
  22:      </asp:DropDownList></td>
  23:  </tr>
  24:  <tr><td><asp:Label ID="lblMsg" runat="server">
  25:         </asp:Label>
  26:      </td>
  27:  </tr>  
  28:  </table>
  29:   </div>
  30:   </form>

Write following code in respective events of page and dropdownlists.

C# CODE
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillCountry();
        }
    }
    protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        int CountryID = Convert.ToInt32(ddlCountry.SelectedValue.ToString());
        FillStates(CountryID);
        ddlCity.SelectedIndex = 0;
    }
    protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
    {
        int StateID = Convert.ToInt32(ddlState.SelectedValue.ToString());
        FillCities(StateID);
    }

    private void FillCountry()
    {
        string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(strConn);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "SELECT CountryID, CountryName FROM Country";
        DataSet objDs = new DataSet();
        SqlDataAdapter dAdapter = new SqlDataAdapter();
        dAdapter.SelectCommand = cmd;
        con.Open();
        dAdapter.Fill(objDs);
        con.Close();
        if (objDs.Tables[0].Rows.Count > 0)
        {
            ddlCountry.DataSource = objDs.Tables[0];
            ddlCountry.DataTextField = "CountryName";
            ddlCountry.DataValueField = "CountryID";
            ddlCountry.DataBind();
            ddlCountry.Items.Insert(0, "--Select--");
        }
        else
        {
            lblMsg.Text = "No Countries found";
        }
    }

    private void FillStates(int countryID)
    {
        string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(strConn);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "SELECT StateID, StateName FROM State WHERE CountryID =@CountryID";
        cmd.Parameters.AddWithValue("@CountryID", countryID);
        DataSet objDs = new DataSet();
        SqlDataAdapter dAdapter = new SqlDataAdapter();
        dAdapter.SelectCommand = cmd;
        con.Open();
        dAdapter.Fill(objDs);
        con.Close();
        if (objDs.Tables[0].Rows.Count > 0)
        {
            ddlState.DataSource = objDs.Tables[0];
            ddlState.DataTextField = "StateName";
            ddlState.DataValueField = "StateID";
            ddlState.DataBind();
            ddlState.Items.Insert(0, "--Select--");
        }
        else
        {
            lblMsg.Text = "No states found";
        }
    }

    private void FillCities(int stateID)
    {
        string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(strConn);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "SELECT CityID, CityName FROM City WHERE StateID =@StateID";
        cmd.Parameters.AddWithValue("@StateID", stateID);
        DataSet objDs = new DataSet();
        SqlDataAdapter dAdapter = new SqlDataAdapter();
        dAdapter.SelectCommand = cmd;
        con.Open();
        dAdapter.Fill(objDs);
        con.Close();
        if (objDs.Tables[0].Rows.Count > 0)
        {
            ddlCity.DataSource = objDs.Tables[0];
            ddlCity.DataTextField = "CityName";
            ddlCity.DataValueField = "CItyID";
            ddlCity.DataBind();
            ddlCity.Items.Insert(0, "--Select--");
        }
        else
        {
            lblMsg.Text = "No Cities found";
        }
    }

VB.NET
Protected Sub Page_Load(sender As Object, e As EventArgs)
 If Not IsPostBack Then
  FillCountry()
 End If
End Sub
Protected Sub ddlCountry_SelectedIndexChanged(sender As Object, e As EventArgs)
 Dim CountryID As Integer = Convert.ToInt32(ddlCountry.SelectedValue.ToString())
 FillStates(CountryID)
 ddlCity.SelectedIndex = 0
End Sub
Protected Sub ddlState_SelectedIndexChanged(sender As Object, e As EventArgs)
 Dim StateID As Integer = Convert.ToInt32(ddlState.SelectedValue.ToString())
 FillCities(StateID)
End Sub

Private Sub FillCountry()
 Dim strConn As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
 Dim con As New SqlConnection(strConn)
 Dim cmd As New SqlCommand()
 cmd.Connection = con
 cmd.CommandType = CommandType.Text
 cmd.CommandText = "SELECT CountryID, CountryName FROM Country"
 Dim objDs As New DataSet()
 Dim dAdapter As New SqlDataAdapter()
 dAdapter.SelectCommand = cmd
 con.Open()
 dAdapter.Fill(objDs)
 con.Close()
 If objDs.Tables(0).Rows.Count > 0 Then
  ddlCountry.DataSource = objDs.Tables(0)
  ddlCountry.DataTextField = "CountryName"
  ddlCountry.DataValueField = "CountryID"
  ddlCountry.DataBind()
  ddlCountry.Items.Insert(0, "--Select--")
 Else
  lblMsg.Text = "No Countries found"
 End If
End Sub

Private Sub FillStates(countryID As Integer)
 Dim strConn As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
 Dim con As New SqlConnection(strConn)
 Dim cmd As New SqlCommand()
 cmd.Connection = con
 cmd.CommandType = CommandType.Text
 cmd.CommandText = "SELECT StateID, StateName FROM State WHERE CountryID =@CountryID"
 cmd.Parameters.AddWithValue("@CountryID", countryID)
 Dim objDs As New DataSet()
 Dim dAdapter As New SqlDataAdapter()
 dAdapter.SelectCommand = cmd
 con.Open()
 dAdapter.Fill(objDs)
 con.Close()
 If objDs.Tables(0).Rows.Count > 0 Then
  ddlState.DataSource = objDs.Tables(0)
  ddlState.DataTextField = "StateName"
  ddlState.DataValueField = "StateID"
  ddlState.DataBind()
  ddlState.Items.Insert(0, "--Select--")
 Else
  lblMsg.Text = "No states found"
 End If
End Sub

Private Sub FillCities(stateID As Integer)
 Dim strConn As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
 Dim con As New SqlConnection(strConn)
 Dim cmd As New SqlCommand()
 cmd.Connection = con
 cmd.CommandType = CommandType.Text
 cmd.CommandText = "SELECT CityID, CityName FROM City WHERE StateID =@StateID"
 cmd.Parameters.AddWithValue("@StateID", stateID)
 Dim objDs As New DataSet()
 Dim dAdapter As New SqlDataAdapter()
 dAdapter.SelectCommand = cmd
 con.Open()
 dAdapter.Fill(objDs)
 con.Close()
 If objDs.Tables(0).Rows.Count > 0 Then
  ddlCity.DataSource = objDs.Tables(0)
  ddlCity.DataTextField = "CityName"
  ddlCity.DataValueField = "CItyID"
  ddlCity.DataBind()
  ddlCity.Items.Insert(0, "--Select--")
 Else
  lblMsg.Text = "No Cities found"
 End If
End Sub

Build and run the code.

Download Sample Code



14

Create Rss Feeds In ASP.NET Consume With Custom Feed Reader

In this example i'm going to describe how to Create Rss Feeds In ASP.NET 2.0,3.5,4.0 And Consume With Custom Feed Reader for your web application using C# VB.Net, First of all we need to create a SQL server database to store and fetch data for feeds.

Create a database and name it RSS and create a table according to image below

And add some data in this table.


Now create a new website in Visual studio and name it RssFeed
Add a new web form and name it Employees.

Go to html source of the page
And add this page directive below the first line on the page

<%@ OutputCache Duration="120" VaryByParam="EmpId" %>


Now go to code behind of Employee page and write this code
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Text;
using System.Data.SqlClient;
public partial class Employees : System.Web.UI.Page
{
string strConnection =
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Clear the response buffer contents
Response.Clear();
Response.ContentType = "text/xml";
XmlTextWriter rssFeed = new XmlTextWriter
(Response.OutputStream, Encoding.UTF8);

//writing RSS tags
rssFeed.WriteStartDocument();
rssFeed.WriteStartElement("rss");
rssFeed.WriteAttributeString("version", "2.0");
rssFeed.WriteStartElement("channel");
rssFeed.WriteElementString("title", "Employee Details");
rssFeed.WriteElementString("link", "http://localhost:2923/RssFeed");
rssFeed.WriteElementString("description", "Details of Employees");

// create sql connection and connect to database
SqlConnection con = new SqlConnection(strConnection);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from Employee";
cmd.Connection = con;
con.Open();
SqlDataReader dReader ;
dReader = cmd.ExecuteReader();
while (dReader.Read())
{
rssFeed.WriteStartElement("item");
rssFeed.WriteElementString("title", dReader["FirstName"].ToString()
+ " " +dReader["LastName"].ToString());
rssFeed.WriteElementString("description", dReader["Location"].ToString());
rssFeed.WriteElementString("link",
"http://localhost:2923/RssFeed/Employees.aspx?EmpID=" +
dReader["ID"]);
rssFeed.WriteElementString("pubDate", DateTime.Now.ToString());
rssFeed.WriteEndElement();
}
dReader.Close();
con.Close();
rssFeed.WriteEndElement();
rssFeed.WriteEndElement();
rssFeed.WriteEndDocument();
rssFeed.Flush();
rssFeed.Close();
Response.End();

}

}
}

Save, build and run the project

Creating custom RSS FEED reader

Create a new project and add new web form to it , name it FeedReader.
Add a new web form and name it anything you want, go to html source of the page and add this
inside <form> tag of the form
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<table class="NormalText" runat="server"
id="tblNews" cellpadding="0" cellspacing="0">
</table>
</td>
</tr>
</table>


Now go to code behind of the page and write this code
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Xml;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string rss =
"http://localhost:2923/RssFeed/Employees.aspx".ToString();
try
{
FetchRssFeeds(rss);
}
catch (Exception ex)
{
}
}
public void FetchRssFeeds(string rss)
{
// Read the RSS feed
WebRequest rssRequest = WebRequest.Create(rss);
WebResponse rssResponse = rssRequest.GetResponse();

Stream rssStream = rssResponse.GetResponseStream();

// Load XML Document
XmlDocument rssDocument = new XmlDocument();
rssDocument.Load(rssStream);

XmlNodeList rssList = rssDocument.SelectNodes("rss/channel/item");

string title = "";
string link = "";
string description = "";

// Loop through RSS Feed items
for (int i = 0; i < rssList.Count; i++)
{
XmlNode rssDetail;

rssDetail = rssList.Item(i).SelectSingleNode("title");
if (rssDetail != null)
{
title = rssDetail.InnerText;
}
else
{
title = "";
}

rssDetail = rssList.Item(i).SelectSingleNode("link");
if (rssDetail != null)
{
link = rssDetail.InnerText;
}
else
{
link = "";
}

rssDetail = rssList.Item(i).SelectSingleNode("description");
if (rssDetail != null)
{
description = rssDetail.InnerText;
}
else
{
description = "";
}

// Populate the HTML table rows and cells
HtmlTableCell cell = new HtmlTableCell();
cell.InnerHtml = "<b><a href='" + link + "' target='new'>"
+ title + "</a></b>";
HtmlTableRow trow = new HtmlTableRow();
trow.Cells.Add(cell);
tblNews.Rows.Add(trow);
HtmlTableCell cell2 = new HtmlTableCell();
cell2.InnerHtml = "<p align='justify'>" + description + "</p>";
HtmlTableRow trow2 = new HtmlTableRow();
trow2.Cells.Add(cell2);
tblNews.Rows.Add(trow2);
}
}
}


Save, build and run the project
Download the sample code




Other Posts:
C#.NET Articles -Cascading DropDownList Populate dropdown based on selection of other dropdown in ASP.NET

Install configure and troubleshooting sql server reporting services 2005

Highlight gridview row on mouse over using javascript in asp.net and C# c-sharp

4

Import CSV Data Into MsSql Server Using Bulk Insert Method

Import CSV Data or File Into MsSql Server Using Sql Bulk Insert Method in Asp.Net. Some time while developing applications using sql server we need to import or insert data into database from data files or csv files.

For this we can use bulk insert method to insert data from csv file to sql server .

1. create a csv file with some data in it like


amit,noida,26

sharad,noida,26

Shobhit,Delhi,25

Now run the following script to load data from this csv file into Database

--Temp table to store the data
CREATE TABLE Test
(
Name VARCHAR(50),
City VARCHAR(50),
Age INT
)
GO

--Bulk insert into Test
BULK INSERT Test
FROM 'C:\test.csv'
WITH
(
FIELDTERMINATOR=',',
ROWTERMINATOR = '\n'
)
GO

--Get all data from Test
SELECT *
FROM Test
GO

--Drop the temp table
DROP TABLE Test
GO


Other SQL Server articles:
1.Import/Export Excel Data into Sql Server using SqlBulkCopy-ASP.NET
2.Install configure and troubleshooting sql server reporting services 2005
3.Ms sql server bulk insert method to import bulk csv data into database
4.Combine Multiple Records Comma Separated In One Column MSSQL
6.Disable browser back button functionality using javascript in ASP.NET
7.Method error 500 / 12031 in implementing ajax cascadingdropdown extender
8.Unable to attach binding handle invalid error in visual studio 2005 while debugging
9.The backup set holds a backup of a database other than the existing database-Sql Server Error 3154

Find More Articles