ReportViewer控件不起作用 [英] ReportViewer Control Not Working

查看:86
本文介绍了ReportViewer控件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个非常基本的ASP.NET页面,它只有一个Reportviewer控件,名为ReportViewer1。

我已经安装了以下代码创建了一个rdlc并在设计时将其链接到报告:

        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 =新的OleDbCommand(SQLCommandText,的SQLConnection);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; OleDbDataAdapter SQLAdapter = new OleDbDataAdapter(SQLCommandText,SQLConnection);
        SQLConnection.Open();
        DataSet thisDataSet = new DataSet();
        SQLAdapter.Fill(thisDataSet);
  

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

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

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

        ReportViewer1.LocalReport.Refresh();

问题是页面总是崩溃并出现以下错误:

建立连接时发生网络相关或特定于实例的错误到SQL Server。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:命名管道提供程序,错误:40 - 无法打开与SQL Server的连接)

现在,我可以在页面上删除数据网格并提供相同的凭据和服务器名称设置并填充gridview没有任何问题;所以我知道这个错误对于真正的问题毫无意义,但我不知道真正的问题是什么,所以我可以解决它。

我欢迎并感谢任何帮助解决的意见。

感谢

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

推荐答案

问题的根本原因是:

你不能由于以下一个或多个原因在SQL Server上调用连接:

1.由于防火墙[硬件或Windows防火墙],SQL Server端口未打开

2.未启用"允许远程连接"属性

3. SQL Server未运行

4.在SQL Server配置中未启用TCP / IP。


有关此错误的更多信息,请参阅: http://blog.sqlauthority.com/2009/ 5月21日/ SQL-SERV ER-FIX-错误提供商命名管道提供商,错误-40可能未打开,一个连接到SQL服务器,微软SQL服务器错误/

因此,此问题与您的报告查看者控制无关

Anand R

The root cause of the problem is : 

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

    1. Due to Firewall [hardware or windows 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 this error 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


这篇关于ReportViewer控件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆