I have a crystal report that is linked to a sql server 2000 database table via OLE DB (ADO) what is the best practice for opening the report to show only a specific record (essential that the user cannot see other records)
1) Open the report and pass a parameter for the key field. If yes could you please provide an example.
2) Create a dataset with just the record relating to the key field and set the reports datasource to the dataset. This is working for the attached code but if there is a simpler way then I'd be happy to use it rather than having to do this for every report I need to open.
3) Some other way
Dim reportPath As String = Server.MapPath("Test123.rpt")
Dim myConnection As New SqlConnection
myConnection.ConnectionString = ConnectionStrings("MyDB").ConnectionString
Dim MyCommand As New SqlCommand()
MyCommand.Connection = myConnection
MyCommand.CommandText = "Select * from TableName where FPlanID = " & intPlanID 'session variable
MyCommand.CommandType = CommandType.Text
Dim MyDA As New SqlDataAdapter()
MyDA.SelectCommand = MyCommand
Dim myDS As New DataSet()
Dim rpt As New ReportDocument
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "ExportedReport")