VB 2008 Crystal report

Crystal report not displaying data

Page 1 of 1

3 Replies - 15127 Views - Last Post: 16 July 2009 - 07:55 AM Rate Topic: -----

#1 km00  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-November 08

VB 2008 Crystal report

Posted 29 January 2009 - 02:58 PM

Im bulding a small project with visual basic 2008 and SQL 2005 express but I'm having issues with crystal report when I send the data from the .mdf data base, the crystal report viewer comes up with the crystal report file format but theres no data on it.

When checking on the dataset I can see its getting the data from the database but its not displaying it on crystal report

here's what I got:

 
	Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=""|DataDirectory|\DB.mdf"";Integrated Security=True;Connect Timeout=30;User Instance=True")
	Dim cmd As New SqlCommand()
	Dim da As New SqlDataAdapter(cmd)
	Dim ds As New DataSet

	Dim strReportName As String


			cmd.Connection = conn
			conn.Open()
			ds.Clear()

			cmd.CommandText = "SELECT * FROM maestras WHERE (maestras.nombre LIKE N'%" & TextBox1.Text & "%')"
			da.Fill(ds, "nombre")
			strReportName = "CrystalReport2"

			Dim strReportPath As String = Application.StartupPath & "\" & strReportName & ".rpt"

			If Not IO.File.Exists(strReportPath) Then
				MsgBox("Error al cargar el reporte", MsgBoxStyle.Critical, "Error")
				'Throw (New Exception("Imposible encontrar el reporte" & vbCrLf & strReportPath))
				conn.Close()
				Exit Sub
			End If

			Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
			rptdocument.Load(strReportPath)
			rptdocument.Refresh()
			rptdocument.SetDataSource(ds.Tables(0))
			rptViewer.ShowRefreshButton = False
			rptViewer.ShowCloseButton = False
			rptViewer.ShowGroupTreeButton = False
			rptViewer.ReportSource = rptDocument
			rptViewer.Refresh()
			conn.Close()




Is This A Good Question/Topic? 0
  • +

Replies To: VB 2008 Crystal report

#2 km00  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-November 08

Re: VB 2008 Crystal report

Posted 03 February 2009 - 08:09 AM

anyone?? help please
Was This Post Helpful? 0
  • +
  • -

#3 sony_ss4  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-July 09

Re: VB 2008 Crystal report

Posted 11 July 2009 - 11:07 AM

Sorry, i need the answer too..
Was This Post Helpful? 0
  • +
  • -

#4 jugalpanchal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-July 09

Re: VB 2008 Crystal report

Posted 16 July 2009 - 07:55 AM

View Postkm00, on 29 Jan, 2009 - 01:58 PM, said:

Im bulding a small project with visual basic 2008 and SQL 2005 express but I'm having issues with crystal report when I send the data from the .mdf data base, the crystal report viewer comes up with the crystal report file format but theres no data on it.

When checking on the dataset I can see its getting the data from the database but its not displaying it on crystal report

here's what I got:

 
	Dim conn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=""|DataDirectory|\DB.mdf"";Integrated Security=True;Connect Timeout=30;User Instance=True")
	Dim cmd As New SqlCommand()
	Dim da As New SqlDataAdapter(cmd)
	Dim ds As New DataSet

	Dim strReportName As String


			cmd.Connection = conn
			conn.Open()
			ds.Clear()

			cmd.CommandText = "SELECT * FROM maestras WHERE (maestras.nombre LIKE N'%" & TextBox1.Text & "%')"
			da.Fill(ds, "nombre")
			strReportName = "CrystalReport2"

			Dim strReportPath As String = Application.StartupPath & "\" & strReportName & ".rpt"

			If Not IO.File.Exists(strReportPath) Then
				MsgBox("Error al cargar el reporte", MsgBoxStyle.Critical, "Error")
				'Throw (New Exception("Imposible encontrar el reporte" & vbCrLf & strReportPath))
				conn.Close()
				Exit Sub
			End If

			Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
			rptdocument.Load(strReportPath)
			rptdocument.Refresh()
			rptdocument.SetDataSource(ds.Tables(0))
			rptViewer.ShowRefreshButton = False
			rptViewer.ShowCloseButton = False
			rptViewer.ShowGroupTreeButton = False
			rptViewer.ReportSource = rptDocument
			rptViewer.Refresh()
			conn.Close()



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1