cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong reportsource shown in crystalreportviewer

Former Member
0 Kudos

Hi,

I'm trying to dynamically get my data source from my database using a query but it shows the wrong report source even though the query and data source is correct.


Public DA As New SqlDataAdapter

Public DS As DataSet 


Public Function executeViaSQL(ByVal sqlquery As String) As DataSet

DS = New DataSet

DA = New SqlDataAdapter(sqlquery, Conn)

DA.Fill(DS, 0) 


Return DS

End Function 


Private Sub formload

Dim RS As New rptDaily

DS = New DataSet

DS = executeViaSQL(query) 'query is public and has a stored query

RS.Load()

RS.SetDataSource(DS.Tables(0))

CrystalReportViewer1.ReportSource = RS

End Sub

The report is showing the default report source even though I've set the report source to a dataset from my database.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi John

Make sure the report does not have the "Saved Data" option enabled. Also, at least for testing purposes enable the option "Verify on 1st refresh".

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow me on Twitter

Former Member
0 Kudos

Ludek Uher wrote:

Make sure the report does not have the "Saved Data" option enabled. Also, at least for testing purposes enable the option "Verify on 1st refresh".

Hello sir Ludek,

I have done this but the report source is still pulling from the database instead of the dataset.

former_member183750
Active Contributor
0 Kudos

What is the database? How are you connecting to it?

What version of .NET are you using?

What version of CR are you using?

- Ludek

Former Member
0 Kudos

SQL Server 2008

VS 2010

Crystal Reports 13.0.2000.0

Public connectionString As String = ""

Public Conn As SqlConnection

Public Class sqlConn

Public Sub OpenConn()

        Try

            Dim sr As New StreamReader(Application.StartupPath & "\SqlConnection.dll") 'Connection string

            connectionString = sr.ReadLine

            Conn = New SqlConnection(connectionString)

            Conn.Open()

            sr.Close()

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

End Class

'Above codes is in a module

Private SQL As New sqlConn

Sub loadMainForm

     SQL.OpenConn()

End sub

former_member183750
Active Contributor
0 Kudos

Hi John

Please see the wiki Troubleshooting Issues with VS .NET Datasets and Crystal Reports - Business Intelligence (BusinessOb... for troubleshooting steps with datasets.

- Ludek

Answers (0)