Hi all,
I am working with a project which includes Crystal Reports in Vb.Net and SQL Server2000 as Back end.

The code in button click is

str5 = "D:\AttendanceReport.rpt"
        If Not IO.File.Exists(str5) Then
            Throw (New Exception("Unable to locate report file:" & vbCrLf & str5))
        End If
str6 = "SELECT * FROM attendance WHERE attendance.dates ='" & str & " '  and   Empid in ( Select Empid from EmployeeDetails where DeptId in (Select Deptid from departments where deptname='" & Convert.ToString(cbxDept.SelectedItem) & "'  ))"

                 MsgBox(str6)
                da5 = New OleDbDataAdapter(str6, sDbConnection)
                da5.Fill(ds5, "Attendance")
                rst.SetDataSource(ds5)
                Dim myReportDocument As ReportDocument
                myReportDocument = New ReportDocument
                myReportDocument.Load(str5)
                myReportDocument.SetDataSource(ds5)
                'Binding report with CrystalReportViewer 
                CRViewer.ReportSource = myReportDocument
                CRViewer.DataBind()

I am getting an error as

'DataBind' is not a member of 'CrystalDecisions.Windows.Forms.CrystalReportViewer'.

I can't understand why the error is Coming
Please Help me

Thanks in advance

What do you have for Imports in this Class?

What do you have for Imports in this Class?

The imports given by me are

Imports System.Data
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Web

The imports given by me are

Imports System.Data
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Web

Hai i think this might be the solution..

Data binding should be done for the Crystal report.. But not For the Report viewer.
So assign the databind method for the crystal report. But not for the crystal report viewer.
Here rpt is the object created for the Crsytal report.
rpt.SetDataSource(ds);
crystalReportViewer1.ReportSource = rpt;

Hope it works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.