本文介绍了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

推荐答案


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

08-15 08:57