Welcome to Dream.In.Code
Become a VB Expert!

Join 137,228 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,897 people online right now. Registration is fast and FREE... Join Now!




print dataset, print preview

 
Reply to this topicStart new topic

print dataset, print preview

nb718
25 Feb, 2007 - 11:07 AM
Post #1

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 4


My Contributions
1. the dataset on hand can't connect to the crystal report viewer... please help!
2. how to design crystalReport1.rpt by pure vb code? (current using blank report)

CODE
    
Private Sub crv()
      Try

         If (txtHospNo.Text <> "" Or txtHKID.Text <> "") Then

            Dim connStr As String = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & dbPath & dbTarget
            Dim conn As OleDbConnection = New OleDbConnection(connStr)
            conn.Open() ' open connection

            Dim sqlStr As String = "SELECT Treatment.TreatDate, TreatmentIma.ImageNo, Treatment.Progress, Treatment.Therapist, Treatment.NextApp FROM (HospitNo INNER JOIN TreatmentIma ON HospitNo.HospNo = TreatmentIma.HospNo) INNER JOIN Treatment ON HospitNo.HospNo = Treatment.HospNo GROUP BY Treatment.TreatDate, TreatmentIma.ImageNo, Treatment.Progress, Treatment.Therapist, Treatment.NextApp, HospitNo.HospNo, HospitNo.HKID HAVING(([HospitNo]![HospNo] = '" & txtHospNo.Text & "' or [HospitNo]![HKID] ='" & txtHKID.Text & "')) ORDER BY Treatment.TreatDate, TreatmentIma.ImageNo, HospitNo.HospNo"

            Dim sqlCmd As OleDbCommand = New OleDbCommand(sqlStr, conn)

            Dim adapter As OleDbDataAdapter = New OleDbDataAdapter(sqlCmd)

            Dim dataset As DataSet = New DataSet

            adapter.Fill(dataset, "Progress")
            adapter.FillSchema(dataset, SchemaType.Source, "Progress")
            Dim dataTable As DataTable = dataset.Tables("Progress")

            Dim rowCount As Integer = dataset.Tables("Progress").Rows.Count


           Dim rpt As CrystalReport1 (added solution explorer)
            rpt.SetDataSource(dataset)
            CrystalReportViewer1.ReportSource = rpt
            CrystalReportViewer1.Show()
  
           conn.Close()

         Else
            MessageBox.Show("No data !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
         End If

      Catch ex As Exception

      End Try
   End Sub



Attached File(s)
Attached File  ertSol.zip ( 360.23k ) Number of downloads: 86
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Print Dataset, Print Preview
25 Feb, 2007 - 02:24 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
1. What error messages are you currently getting when connecting the dataset to the report?

2. Give this tutorial a try.
http://www.codeproject.com/vb/net/CrystalR...ts_in_VBNET.asp
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:06PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month