Question crystal report problem

Joined
Jan 5, 2009
Messages
8
Programming Experience
Beginner
I had the following code to display crystal report based on the sql.

VB.NET:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        conKk.Open()
       
        Dim strReportPath As String = "C:\Documents and Settings\Chee Mun\Desktop\FYPvb\FYP\CrystalReport1.rpt"
        MessageBox.Show(strReportPath)
        Dim mySelect As SqlCommand

        mySelect = New SqlCommand("Select * from Song", conKk)

        Dim mySqlDataAdapter As New SqlDataAdapter(mySelect)

        Dim mydsSong As New DataSet

        mySqlDataAdapter.Fill(mydsSong, "Song")
        Dim objRpt As New ReportDocument
        objRpt.Load(strReportPath)

        objRpt.SetDataSource(mydsSong.Tables("Song"))
        CrystalReportViewer1.ShowRefreshButton = False
        CrystalReportViewer1.ShowCloseButton = False
        CrystalReportViewer1.ShowGroupTreeButton = False

        CrystalReportViewer1.ReportSource = objRpt
        CrystalReportViewer1.Refresh()
        conKk.Close()
    End Sub

But the problem occured in objRpt.SetDataSource(mydsSong.Tables("Song")),it stated that no tables is found but my database is having this table.

anyone could guide me?


I appreciate it.
 

Latest posts

Back
Top