Issue with crystal report

Closed
mikeoe2003 Posts 24 Registration date Thursday November 1, 2012 Status Member Last seen March 27, 2014 - Feb 1, 2013 at 06:06 AM
apprabhu Posts 2 Registration date Sunday February 3, 2013 Status Member Last seen February 3, 2013 - Feb 3, 2013 at 07:40 AM
Hello,
Please i need help with getting a crystal report to display data find my code below

Private Sub BtnCRPT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCRPT.Click
Try

Dim con As New OleDbConnection
con.ConnectionString = _
"provider=Microsoft.JET.OLEDB.4.0; " & _
"data source = '" & Application.StartupPath & "\school_record.mdb'"
Dim ds As New DataSet
Dim dt As New DataTable

Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("select * from student_info ", con)
ds.Tables.Add(dt)
da.Fill(ds)

Dim crReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
crReportDocument = New mcrystal
crReportDocument.SetDataSource(dt)
CrystalReportViewer1.ReportSource = crReportDocument

con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message & " - " & ex.Source)
End Try
End Sub




1 response

apprabhu Posts 2 Registration date Sunday February 3, 2013 Status Member Last seen February 3, 2013
Feb 3, 2013 at 07:40 AM
Change this

da = New OleDbDataAdapter("select * from student_info ", con)
ds.Tables.Add(dt)
da.Fill(ds)

Dim crReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
crReportDocument = New mcrystal
crReportDocument.SetDataSource(dt)


to

da = New OleDbDataAdapter("select * from student_info ", con)
da.Fill(ds)

Dim crReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
crReportDocument = New mcrystal
crReportDocument.SetDataSource(ds) 


When you are using single table data just use dataset only.
0