Showing posts with label N06. Reporting Issues. Show all posts
Showing posts with label N06. Reporting Issues. Show all posts

VB.NET: Crystal Report dengan VS2005

Berikut saya ringkaskan Langkah-2 kunci dalam menyusun sebuah report dengan Crystal Report di lingkungan Visual Studio 2005. Bahasa yang digunakan ialah VB.NET.




  1. Buat file DataSet .xsd
  2. Buat file Report, atur sumber datanya ke DataSet di atas
  3. Buat dataSet yg terhubung ke database
  4. Buat form baru, tambahkan Crystal Report Viewer

Berikut kodenya:

Dim sIn(0) As String

Dim da As New OleDbDataAdapter
Dim cm As New OleDbCommand
Dim cn As OleDbConnection
rpt = New crReport

Dim ds As New DataSet
cn = New OleDbConnection(infoSession.Login_Connection)
cn.Open()

With cm
.Connection = cn
.CommandText = "Select kdprop, kddati2 from vw_tabel"
.CommandType = CommandType.Text
.ExecuteNonQuery()
End With

da.SelectCommand = cm

da.Fill(ds, "Databaru")
rpt.SetDataSource(ds)

With Me.CrstalReportViewer1
.ReportSource = rpt
.Visible = True
.Refresh()
.Show()
End With


Satu aspek penting yang perlu dicatat ialah bagaimana dataset yang kita buat berkomunikasi dengan Crystal Report kita. Dalam hal ini yang menjadi mediator ialah dataset dalam .xsd kita. Hasil perolehan query dalam kode dataset kita dimasukkan melalui dataset dalam .xsd ini.

Dengan me-refresh data CR kita, perubahan dari struktur data biasanya akan memberikan pesan berikut ini:

Note:

  1. Misalkan kita ingin mengupdate struktur dari sumber data yang telah berubah, maka kita menuju ke file dataset xsd kita dulu. Setelah perubahan struktur tercermin disitu, baru kita menuju ke Crystal Reportnya.
  2. Bagaimanakah cara kita untuk mengupdate xsd? Ambil dataset yang hendak dirubah, klik kanan dan pilih configure, tentukan query yang dikehendaki pada kotak dialog dan tekan Finish.
2007,
widya

How to Design sub report with classical CR 8.5 in VB6 IDE

Widyanahar: 3 march: 2008

I am trying to write this article due to the fact that it is uneasy to get howtos or step-by-steps info for this issue, even with our google, it is still hard to find out.

Thought that many of you experiencing the same problem on this! This article should be useful for those who is still in middle of legacy system which is running crystal report 85 with VB6 desperately. (You know that this is 2008).



Here is the code for accessing the subreport:

cr.DiscardSavedData

cr.Database.SetDataSource rsmain, 3, 1

cr.Subreport1.OpenSubreport.Database.SetDataSource rssub, 3, 1

cr.Subreport1.OpenSubreport.Database.Verify

frmReportView.CRViewer1.ReportSource = cr

frmReportView.CRViewer1.ViewReport

frmReportView.Show vbModal

Note: you use Active Data, prepare two ADO Recordset for main report dan subreport , say both as rsmain as rssub.

Here is the step-by-step:

  1. The report files is included within the vb projects (.dsr file) rathe than .rpt, representing the main report and sub report.
  2. The Sub Report file will be placed in one of sections within main report design, by insert report procedure (rightclick the design form, insert/subreport)
  3. There must a field as conjuction/link between main report and subreport. That is a field that exist in rsmain and rssub. In this example, the field is CustomerID.

here is the menu to prepare the link :




4. After subreport insertion, subreport created once will not be used anymore for editing. You should use the subreport inserted by rightclicking subreport part in the mainreport form and click Edit SubReport as depicted below.


5. After step 4, you must have tab main Report dan Sub Report named crDetail. From this sub report, you should do your design work.


hope this helpful.


wid, 2008