带有vb.net 2016和MSAccess的Reportviewer

时间:2018-09-15 18:44:40

标签: vb.net reporting-services ms-access-2016

我正在做一个上课的项目。我正在使用reportviewer从名为Fitnesscompanydb.accdb的数据连接中提取数据。现在它总是抛出此错误。

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

Public Class frmSignupReportQuery
Private Sub frmSignupReportQuery_Load(sender As Object, e As EventArgs) 
Handles MyBase.Load
    Dim startingdate As String = frmSignupReport.SignupDateStart.Text
    Dim endingdate As String = frmSignupReport.SignupDateEnd.Text

    Dim strConnectionString As String = "Data Source=(local)" '; Initial 
Catalog=fitnessCompanyDB.accdb; "
    Dim ds As New DataSet()
    Dim da As New SqlDataAdapter()
    Dim cmd As New SqlCommand("SELECT * FROM Memberbase WHERE 
Memberbase.Signupdate = BETWEEN #" & startingdate & "# and #" & endingdate & 
"#")
    cmd.CommandType = CommandType.Text
    cmd.Connection = New SqlConnection(strConnectionString)
    da.SelectCommand = cmd

    da.Fill(ds, "DataSet1")

    Dim rds As New ReportDataSource("DataSet1", ds.Tables(0))
    Me.ReportViewer1.LocalReport.ReportPath = "@\SignupReport.rdlc"
    Me.ReportViewer1.LocalReport.DataSources.Clear()
    Me.ReportViewer1.LocalReport.DataSources.Add(rds)
    Me.ReportViewer1.RefreshReport()
End Sub
End Class

我知道它可能会引发此错误,因为它没有正确命名,因此找不到文件。如何添加正确的文件位置以便可以找到它?

0 个答案:

没有答案