我正在为课堂项目工作,我们需要生成水晶报告。我正在使用Visual Studio 2013并使用Crystal Reports for SP15。我创建了一个报告,并在一个空白的asp.net webform上放置了一个水晶查看器,但是当我运行webform时,它要求数据库登录。有没有人遇到过这个问题,或者有人可以帮我吗?谢谢!
**以下是我的网页代码:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.Data.SqlClient
Partial Class Default2
Inherits System.Web.UI.Page
Dim MyReport As SqlConnection
Dim COMMAND As ReportDocument
Dim ALMOST As SqlCommand
Dim adp As SqlDataAdapter
Dim DT As DataSet
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim commandString As String = ConfigurationManager.ConnectionStrings("HouseSwappingConnectionString").ConnectionString
Using con As New SqlConnection(commandString)
Using cmd As New SqlCommand("Select * from ListTable", con)
cmd.CommandType = CommandType.Text
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
Dim HouseSwap As New ReportDocument
HouseSwap.Load(Server.MapPath("CrystalReport.rpt"))
HouseSwap.SetDataSource(ds.Tables(0))
CrystalReportViewer1.ReportSource = HouseSwap
CrystalReportViewer1.DataBind()
CrystalReportViewer1.RefreshReport()
End Using
End Using
End Sub