str1 = "select distinct [Sched_Code] as [No.], [Course], [Year], [Section], [Batch]," & _
                                             " [Subject],[subject_desc],[units], [Time], [Day], [Room], [Instructor], [Schoolyr] as [S.Y.], [Semester] as [Sem] from tblSchedule, tblcurriculum where tblschedule.subject=tblcurriculum.subjects"
    Dim dt As New DataTable
    dt = ConnectDatabase(str1)
    rpt.SetDataSource(dt)
    CrystalReportViewer1.ReportSource = rpt



 help, i cant see content of my data generated from the tblschedule and tblcurriculum.
 i dont encounter any error.

Recommended Answers

All 3 Replies

I am not so sure that query is returning anything.

You have to give a table.column on the select when two tables are being passed in on the FROM clause.

Try adding an alias and prefixing your columns.

For Example:

str1 = "SELECT DISTINCT ts.[Sched_Code] As [No], ts.[Course], ts.[Year]........ FROM tblSchedule ts, tblCurriculum tc WHERE ts.[Subject] = tc.[Subjects]"

In database make a view of two tables first then query the view. in crystal report

The alias should match the column name you are about to show in the report.

Ex. You want Sched_Code to show inthe report from your query of 2 tables.
First put Sched_Code in the Crystal Report then make your query. Your query
should be this.

Select [ts.Sched_Code] as [Sched_Code] From ts, tblSchedule

Note: If Sched_Code doesn't appear in other tables, don't use any alias.
Crystal Report is sensitive to Column Names based on my experience on
handling it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.