Visual Studio Development Bookmark and Share   
 index > Visual Studio Report Controls > ReportViewer Control Not Working
 

ReportViewer Control Not Working

Hi,

I have created a very basic ASP.NET page that has only 1 reportviewer control on it called ReportViewer1.

I have installed the following code after having created an rdlc and linked it to the report at design time:

        string SQLConnectionString = "Provider=SQLNCLI10;Server=<MyServerName>;Database=<MyDatabaseName>;Uid=asadmin; Pwd=<password>;";

        ReportViewer1.Visible = true;

        string SQLCommandText = "SELECT event_end_datetime, extract_ct FROM Event_log";
        OleDbConnection SQLConnection = new OleDbConnection(SQLConnectionString);
        //OleDbCommand SQLCommand = new OleDbCommand(SQLCommandText, SQLConnection);
        OleDbDataAdapter SQLAdapter = new OleDbDataAdapter(SQLCommandText, SQLConnection);
        SQLConnection.Open();
        DataSet thisDataSet = new DataSet();
        SQLAdapter.Fill(thisDataSet);
  

        ReportDataSource datasource = new
          ReportDataSource("DataSet_EventsLogging",
          thisDataSet.Tables[0]);

        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(datasource);

        int count = thisDataSet.Tables[0].Rows.Count;

        ReportViewer1.LocalReport.Refresh();

The problem is the page always crashes with the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Now, I can drop a datagrid on the page and provide the same credentials and servername settings and populate the gridview without any issues at all; so I know that this error is meaningless for the real issue but I have no clue what the real issue is so I can resolve it.

I welcome and appreciate any input to assist in resolution.

thanks
mindscape777  Friday, October 16, 2009 7:18 PM

The root cause of the problem is :

You are not able toinvoke a connection on a SQL Server due to the one/more of the following reasons :

1. Due to Firewall , SQL Server ports not opened

2. Allow Remote Connections attribute is not enabled

3. SQL Server is not running

4. TCP/IP is not enabled in SQL Server Configuration .

For more info on thiserror refer : http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/

Hence , this issue is unrelated to your reportviewer control

Anand R

Anand.Ranganathan  7 hours 24 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• Error on Control
• VB.NET REPORT VIEWER IN A MANAGED DESKTOP ENVR. --> 2 Q's
• Crystal Subreport
• How to convert rdlc to rdl ?
• Viewing reports hosted on report server 2005 from asp.net 1.1.4322
• simple phone number format for vss 2005
• Has anyone commercially created a local mode viewer control that will process the dataset in an RDL file?
• Dynamically changing ReportViewer properties
• Errors with custom code assembly
• Parameter Dialog Looks Different