SetDataSource not working with Crystal Reports .NET in VB.NET 
Author Message
 SetDataSource not working with Crystal Reports .NET in VB.NET

Below is the code I use to show a report through a report viewer
control.  It seems to work fine, except that it displays all the data
in the selected view, rather than just the data defined by the "where"
clause as I've typed below.  I've tried about a million different
combinations of properties and methods, none of which make a
difference, and the help files seem to indicate that I'm doing this
right.  Can someone tell me why the "setdatasource" doesn't seem to be
doing its job?  Thanks,

Andrew

        Dim myReport As New
CrystalDecisions.CrystalReports.Engine.ReportDocument()
        Dim objTable As CrystalDecisions.CrystalReports.Engine.Table
        Dim objLoginInfo As CrystalDecisions.Shared.TableLogOnInfo
        Dim dsNetwork As New DataSet()

        sReport = System.Configuration.ConfigurationSettings.AppSettings("report_path")
& "\myReport.rpt"
        Dim strNetworkSQL As String = "select * from myView where
season_id = " & g_yearID
        Dim daNetwork As New SqlDataAdapter(strNetworkSQL, g_oConn)
        daNetwork.Fill(dsNetwork)
        myReport.Load(sReport)
        myReport.SetDataSource(dsNetwork)
        For Each objTable In myReport.Database.Tables
            objLoginInfo = objTable.LogOnInfo
            objLoginInfo.ConnectionInfo.Password = "xxx"
            objTable.ApplyLogOnInfo(objLoginInfo)
        Next
        Dim frmReport As New frmReportPreview()
        frmReport.ReportViewer.ReportSource = myReport
        frmReport.ReportViewer.DisplayGroupTree = False
        Cursor.Current = Cursors.Default
        frmReport.ShowDialog()



Fri, 22 Jul 2005 22:55:58 GMT  
 SetDataSource not working with Crystal Reports .NET in VB.NET
Never mind about the problem above.  Finally got it working by
changing this line:

Quote:
>         myReport.SetDataSource(dsNetwork)

to this line:

          myReport.SetDataSource(dsNetwork.Tables(0))

Don't know why it's necessary to add the "tables" part, as it doesn't
seem to say anything about that in the help.

In any case, now I have another question.  Does anyone know how to
design a Crystal Report using the design wizard (.NET version), when
the underlying query you want to design it from is actually a function
call (rather than a table or view)?

Andrew



Sat, 23 Jul 2005 22:35:58 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Crystal Reports 8.5 (VB6) to Crystal Reports NET (VB.NET) conversion

2. vb .net crystal reports not compatible with Crystal Reports 8.5

3. VB.net and crystal reports.net Multiple reports

4. Exporting crystal reports from visual studio.net is not working in the final release

5. i am using vb.net and crystal reports for visual studio.net

6. Error in temp file in running crystal report for .net in vb.net

7. Crystal Reports from ASP.NET without compiling VB.NET on SQL/ADO changes

8. Web Reports (ASP.NET and Crystal Reports for .Net)

9. Crystal Reports Does Not Show in VisualStudio(VB).Net Server Explorer

10. crystal.net report from asp.net created (temporary) table

11. problem with crystal report for .net in asp.net

12. Linking Crystal Report with a stored Procedure -- crystal report for visual studio.net

 

 
Powered by phpBB® Forum Software