Issue with crystal report

[Closed]
Report
Posts
25
Registration date
Thursday November 1, 2012
Status
Member
Last seen
March 27, 2014
-
Posts
2
Registration date
Sunday February 3, 2013
Status
Member
Last seen
February 3, 2013
-
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 reply

Posts
2
Registration date
Sunday February 3, 2013
Status
Member
Last seen
February 3, 2013

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.