我需要一些帮助才能在VB 2005中创建Crystal Reports。
我想使用datetimepicker在两个日期之间过滤数据(例如从日期到日期)。 我正在使用SQL Server 2000进行连接。
感谢您的链接,但我正在尝试使用记录选择公式....
这是我的代码:
Try
Dim cryRpt As New ReportDocument
With cryRpt
.FileName = ("C:\Documents and Settings\Ratna Ayu\My Documents\Visual Studio 2005\Projects\Denda\Denda\CrystalReport1.rpt")
.RecordSelectionFormula = "{pinjam.tglkembali}>='" & DateTimePicker1.Value.ToString("dd/MM/yyyy") & "' and {pinjam.tglkembali} =<'" & DateTimePicker2.Value.ToString("dd/MM/yyyy") & "'"
End With
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
Catch ex As Exception
MsgBox("tdk ada data", , "")
End Try
答案 0 :(得分:0)
看一下这个链接
How to Load and Display Crystal Reports in VB.NET
以下代码显示了如何加载 VB.NET中的Crystal Reports,解决了所有问题 登录问题,包括子 报告和参数传递。您可以 只需拨打电话即可查看报告 它所需的功能 参数。
答案 1 :(得分:0)
Public Sub ConfigureCrystalReportsPhotoAlbum2012ByDateNew()
On Error Resume Next
sReport = New ReportDocument()
Dim reportPath As String = Application.StartupPath & "\" & "PhotoAlbum2012.rpt"
sReport.Load(reportPath)
Dim selectionFormula As String = "{MemberDetails.Birthdate} >= #" _
& CDate(frmCustomReport.txtFrom.Text) _
& "# and {MemberDetails.Birthdate}" _
& "<=" _
& "#" _
& CDate(frmCustomReport.txtTo.Text) _
& "#"
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
'myConnectionInfo.ServerName = "192.168.0.2\SQLExpress" 'Network
myConnectionInfo.ServerName = ".\SQLExpress" 'Local
myConnectionInfo.DatabaseName = "Photo Album 2012"
myConnectionInfo.UserID = "limitedPermissionAccount"
myConnectionInfo.Password = ""
myConnectionInfo.IntegratedSecurity = True
SetDBLogonForReport(myConnectionInfo, sReport)
frmMain.CrystalReportViewerMain.SelectionFormula = selectionFormula
frmMain.CrystalReportViewerMain.ReportSource = sReport
frmMain.CrystalReportViewerMain.Zoom(100)
frmMain.CrystalReportViewerMain.BackColor = Color.AliceBlue
End Sub
答案 2 :(得分:0)
这远远只是使用这个代码非常容易。
我为它构建了一个示例联系人应用程序和报告,并使用下面的代码根据开始和结束日期过滤联系人。 DateTimePicker1
已开始,DateTimePicker2
已结束。
Private Sub filter_dates()
Dim objcr As New CrystalReport1
Dim da As New MySqlDataAdapter("select * from Contacts where CDate>='" & CDate(DateTimePicker1.Text) & "' and CDate<='" & CDate(DateTimePicker2.Text) & "' ", conn)
Dim dt As New DataTable
da.Fill(dt)
objcr.SetDataSource(dt)
CrystalReportViewer1.ReportSource = objcr
CrystalReportViewer1.RefreshReport()
End Sub