Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello, I want to make a crystal report from table relation.

I've make for a non relation table, and the record success shown in the crystal report.

But, when I try for a relation table, the record is not displayed in the crystal report. I try with the same way for non-relation table, but it's work.

Here is my code :
VB
Option Explicit On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data.SqlClient
Public Class PrintJadwalKuliah

    Dim xKoneksi As New SqlConnection
    Dim xAdapter As New SqlDataAdapter
    Dim obj_RepDoc As New ReportDocument
    Dim xDataset As New _FKIP_UNILAKDataSet()
    Private Sub PrintJadwalKuliah_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        xKoneksi.ConnectionString = "Data Source=RAGAZ-PC\SQLEXPRESS;Initial Catalog=FKIP-UNILAK;Integrated Security=True"
        xAdapter = New SqlDataAdapter("SELECT Hari.nama_hari , Jam.jam_kuliah , Jam.selesai , Ruang.Nama_Ruangan FROM slot INNER JOIN Hari ON slot.Id_hari = Hari.Id_hari INNER JOIN Jam ON slot.Id_Jam = Jam.Id_Jam INNER JOIN Ruang ON slot.Id_Ruangan = Ruang.Id_Ruangan", xKoneksi)
        xAdapter.Fill(xDataset, "Jadwal")
        obj_RepDoc = New CrystalReport_slotcoba
        obj_RepDoc.SetDataSource(xDataset)
        CrystalReportViewer1.ReportSource = obj_RepDoc
    End Sub
End Class

When I try to show the "Select query" to datagrid view, the record succes shown ( I think my "select Query" is fine), So what is the solution for this one??

Sorry, my english bad, I'm an indonesian :)
Posted
Updated 13-May-11 6:10am
v3

1 solution

Create a view in your DB with that query. And then just
SELECT * FROM YourNewView


This should work without problems.
 
Share this answer
 
Comments
Abdi tombang 14-May-11 0:52am    
I've make a view "JadwalKuliah". And I'm using "SELECT * FROM JadwalKuliah".
But the record still not shown in crystal report :(
What is the problem now?

Here my code now:

Option Explicit On
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data.SqlClient
Public Class PrintJadwalKuliah
Dim xKoneksi As New SqlConnection
Dim xAdapter As New SqlDataAdapter
Dim obj_RepDoc As New ReportDocument
Dim xDataset As New _FKIP_UNILAKDataSet()
Private Sub PrintJadwalKuliah_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
xKoneksi.ConnectionString = "Data Source=RAGAZ-PC\SQLEXPRESS;Initial Catalog=FKIP-UNILAK;Integrated Security=True"
xAdapter = New SqlDataAdapter("SELECT * FROM [FKIP-UNILAK].[dbo].[JadwalKuliah]", xKoneksi)
xAdapter.Fill(xDataset, "JadwalKuliah")
obj_RepDoc = New CrystalReport_Jadwal
obj_RepDoc.SetDataSource(xDataset)
CrystalReportViewer1.ReportSource = obj_RepDoc
End Sub

End Class
Abdi tombang 14-May-11 23:11pm    
It work, thanks a lot :D
luisnike19 16-May-11 9:59am    
You're welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900