水晶报表vb.net和Mysql [英] Crystal Report vb.net and Mysql
本文介绍了水晶报表vb.net和Mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个名为frmviewreport.vb的表单,并在其上放置了一个名为rptViewer的CrytalReportViewer.
我想显示从MySQl db获得的数据在报表查看器上的记录.
在此先感谢.
I have created a form called frmviewreport.vb and I have placed on it the CrytalReportViewer named rptViewer.
I want to show a record on the report viewer from data I get from MySQl db.
Thanks in advance.
推荐答案
如果您是本主题的初学者,请
您必须访问此链接[ ^ ]
以及从Crystal报表到您所需的一切,您都将学到它
从这里逐步轻松实现
祝你好运
并玩得开心.
If you are a beginner in this Subject then
you must visit this link [^]
and From Crystal reports to what ever your need you will learn it
from here stepwise and in easy way
Best of luck
and have Fun..
为此,您必须使用
SQL查询字符串的Crystal报表
可以在此链接中找到[ ^ ]
通过查询并将条件放在要搜索的必填字段上
For this you have to use
Crystal Reports from SQL Query String
which can be found here in this link [^]
pass the query and in where condition put the required field on which you want to search
我要感谢大家对我的帮助.最后,让我描述一下我为解决VB.NET,Crystal Reports和MySQL的问题所做的工作:
我在此链接 http://www.codeproject.com/KB/database/MySQLCrystal上遵循此C#页面上的说明.aspx
以及此链接上的代码(我只使用了子例程的最后四行). net-informations.com/crystal-report/crystal_report_from_sql_query_string.htm
并为VB.NET编写了如下代码:
I would like to thank all you guys for helping me. Finally let me just describe what i did to solve this problem of VB.NET, Crystal Reports and MySQL:
I followed instructions on this page for C# on this link http://www.codeproject.com/KB/database/MySQLCrystal.aspx
and the code on this link (i just used the last four lines of the subroutine) http://vb.net-informations.com/crystal-report/crystal_report_from_sql_query_string.htm
and made the code for VB.NET as follows:
Imports CrystalDecisions.CrystalReports.Engine
Imports MySql.Data.MySqlClient
Public Class frmViewReport
Dim conn As MySqlConnection
Dim daCompanies As New MySqlDataAdapter()
Dim dsCompanies As New DataSet()
Private Sub frmViewReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New MySqlConnection
Try
With conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = cnString
.Open()
End With
Catch ex As MySqlException
MsgBox(ex.ToString)
End Try
Try
Dim qryCompanies As String = "SELECT * FROM `tbl_permits`"
daCompanies.SelectCommand = New MySqlCommand(qryCompanies, conn)
Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(daCompanies)
daCompanies.Fill(dsCompanies, "tbl_permits")
Catch ex As MySqlException
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
Dim objRpt As New Permit
objRpt.SetDataSource(dsCompanies.Tables("tbl_permits"))
rptViewer.ReportSource = objRpt
rptViewer.Refresh()
'This is the other Option i did not use... But it worked.
'Dim cryRpt As New ReportDocument
'cryRpt.Load("C:\Users\Josh\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\Permit.rpt")
'rptViewer.ReportSource = cryRpt
'rptViewer.Refresh()
End Sub
End Class
我希望这对其他人有用...
I hope this would be useful for someone else......
这篇关于水晶报表vb.net和Mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文