1 Replies - 6176 Views - Last Post: 25 February 2007 - 03:24 PM Rate Topic: -----

#1 nb718  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-February 07

print dataset, print preview

Post icon  Posted 25 February 2007 - 12:07 PM

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)

	 
 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)



Is This A Good Question/Topic? 0
  • +

Replies To: print dataset, print preview

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: print dataset, print preview

Posted 25 February 2007 - 03:24 PM

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

2. Give this tutorial a try.
http://www.codeproje...ts_in_VBNET.asp
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1