skinpower
Oct 25th, 2006, 11:28 PM
Hi, I am trying to produce this with Crystal Report and VB 2005.
The problem is that the following sql query works fine in Access, and I could get a perfect report out of it. however, when I trying to use this query in VB, data won't show in the crystal report. I don't even get an error on this code. So, I couldn't figure it out why I don't get the result on Crystal Report.
by the way, the result should be 5 distinct records and no field is NULL.( that's what I got from ACCESS & DatagridView)
So, would you help me?
===================================================
Private Sub CRV1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CRV1.Load
Dim s As String
s = "SELECT FirstName, LastName, staff, a_time, reason FROM tblconsumer " & _
"Join tblattendance on tblattendance.c_id = tblconsumer.c_id " & _
"Join tblcode on tblattendance.a_id = tblcode.a_id " & _
"WHERE tblattendance.a_date = @date"
Dim today As String = Date.Now.ToString("MM/dd/yyyy")
today = today & " 12:00:00 AM"
RepdbDA.SelectCommand = New SqlCommand()
RepdbDA.SelectCommand.Connection = RepdbConnection
RepdbDA.SelectCommand.CommandText = s
RepdbDA.SelectCommand.CommandType = CommandType.Text
RepdbDA.SelectCommand.Parameters.AddWithValue("@date", today)
RepdbDS = New DataSet()
RepdbDA.Fill(RepdbDS, "rptdar")
Dim dt As DataTable = New DataTable
dt = RepdbDS.Tables(0)
Dim DAReport = New rptdar() ' rptdar = new instance of C R
DAReport.SetDataSource(dt)
CRV1.ReportSource = DAReport
End Sub
The problem is that the following sql query works fine in Access, and I could get a perfect report out of it. however, when I trying to use this query in VB, data won't show in the crystal report. I don't even get an error on this code. So, I couldn't figure it out why I don't get the result on Crystal Report.
by the way, the result should be 5 distinct records and no field is NULL.( that's what I got from ACCESS & DatagridView)
So, would you help me?
===================================================
Private Sub CRV1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CRV1.Load
Dim s As String
s = "SELECT FirstName, LastName, staff, a_time, reason FROM tblconsumer " & _
"Join tblattendance on tblattendance.c_id = tblconsumer.c_id " & _
"Join tblcode on tblattendance.a_id = tblcode.a_id " & _
"WHERE tblattendance.a_date = @date"
Dim today As String = Date.Now.ToString("MM/dd/yyyy")
today = today & " 12:00:00 AM"
RepdbDA.SelectCommand = New SqlCommand()
RepdbDA.SelectCommand.Connection = RepdbConnection
RepdbDA.SelectCommand.CommandText = s
RepdbDA.SelectCommand.CommandType = CommandType.Text
RepdbDA.SelectCommand.Parameters.AddWithValue("@date", today)
RepdbDS = New DataSet()
RepdbDA.Fill(RepdbDS, "rptdar")
Dim dt As DataTable = New DataTable
dt = RepdbDS.Tables(0)
Dim DAReport = New rptdar() ' rptdar = new instance of C R
DAReport.SetDataSource(dt)
CRV1.ReportSource = DAReport
End Sub