Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

crystal reports integration with sql server and visual studio 2010

when I am trying to open a crystal report through code ( visual basic 2010 ) I get the error

the report has no tables

I am using SQL SERVER 2008 R2

HERE IS THE CODE I WROTE

Imports System.Data

Imports System.Data.OleDb

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Windows.Forms

Imports CrystalDecisions.Shared

Public Class frmRep

Dim objConnection As New OleDbConnection("Provider=SQLOLEDB;Data Source=ASHRAF-PC\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=TEST")

Dim objDataAdapter As New OleDbDataAdapter()

Dim objDataSet As New DataSet()

Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load

End Sub

Private Sub frmRep_Load(sender As Object, e As System.EventArgs) Handles Me.Load

Dim cr As New ReportDocument

objDataAdapter.SelectCommand = New OleDbCommand()

objDataAdapter.SelectCommand.Connection = objConnection

objDataAdapter.SelectCommand.CommandType = CommandType.Text

objDataAdapter.SelectCommand.CommandText = "select * from bands"

objConnection.Open()

objDataAdapter.Fill(objDataSet, "bands")

objConnection.Close()

cr.Load("D:\MY VB 2010 PROJECTS\test2\test2\CrystalReport1.rpt")

cr.SetDataSource(objDataSet.Tables("bands"))

CrystalReportViewer1.ReportSource = cr

CrystalReportViewer1.Refresh()

End Sub

End Class

Former Member
Not what you were looking for? View more on this topic or Ask a question