在vb.net中的crystal report中绑定xml时无法加载数据库信息 [英] Failed to load database information while binding xml in crystal report in vb.net

查看:77
本文介绍了在vb.net中的crystal report中绑定xml时无法加载数据库信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我

我正在使用Vs 2005和水晶报告11.5当我运行设置并尝试查看下面的Crystal报告错误来吧。当运行时这个代码在我的机器上,当我运行安装程序并尝试查看报告然后错误来运行时它工作正常。我使用XML来结合数据和晶体报告。该代码就像这样



ds.WriteXml(Application.StartupPath& " \Reports\AverageAnalysis.xml"


ds.WriteXmlSchema(Application.StartupPath& " \Reports\AverageAnalysisSchema.xsd"


'################################## ################################################## #####


crReportDocument.Load(Application.StartupPath& " \ Reportport \rptAverageAnalysis.rpt"


并且Develpoer机器中没有错误当我安装设置时在客户端然后错误进入报告,绑定水晶与xml.And在另一个报告中,ado.net连接将正常工作。


请帮助我


没能广告数据库信息


文件错误:"C:\doument\..\\ ... .rpt")


请帮助它非常紧急


代码就像


私人 功能 GenerateReport() 布尔


Dim ds,subDs As New DataSet


< font color ="#0000ff"size = 2> Dim strSql As 字符串


Dim pvCollection As ParameterValues


昏暗 pdv As ParameterDiscreteValue


Dim crtableLogoninfos As TableLogOnInfos


Dim crtableLogoninfo As TableLogOnInfo


Dim crConnectionInfo As New ConnectionInfo


Dim CrTables As Tables


Dim CrTable 作为


Dim sqladpt As SqlDataAdapter


Dim strConnection As 字符串


如果 con.State = ConnectionState.Open 那么 con.Close()


strConnection = " server = 192.3; Database = BM123; User Id = sa; Password = dewe"


con.ConnectionString = strConnection 'ReadXML()


con.Open()


尝试


GenerateReport = False


strSql = " SPAvgAnalysisDatewiseLocWise'" & txtLocationCode.Text.Trim& "','" & _


txtTradeCode.Text.Trim& "','" &格式(dtpFromDate.Value, " yyyy / MM / dd" )& "','" & _


格式(dtpToDate.Value, " yyyy / MM / dd" )& "','S','','','APP'"


sqladpt = SqlDataAdapter(strSql,con)


sqladpt.Fill(ds)


'############## ################################################## ########################


< font color ="#008000"size = 2>'生成报告我们需要xml数据和模式文件,生成报告后


'无需创建这些文件,我们可以直接将数据集绑定到报告


如果 ds 没什么 T母鸡


If ds .Tables(0).Rows.Count = 0 然后


MessageBox .Show( "抱歉没有数据......"


返回 False


结束 如果


ds.WriteXml(Application.StartupPath& " \Reports\AverageAnalysis.xml"


ds .WriteXmlSchema(Application.StartupPath& " \Reports\AverageAnalysisSchema.xsd"


'########################## ################################################## #############


crReportDocument.Load(Application.StartupPath& " \Reports\rptAverageAnalysis.rpt"


'使用crConnectionInfo


'。ServerName =" 192.168.29.152"


'.DatabaseName =" BMS"


" .UserID =" sa"


'。Password =" gitman"


'以

结尾

'CrTables = crReportDocument.Database.Tables


'对于CrTables中的每个CrTable


'crtableLogoninfo = CrTable.LogOnInfo


'crtableLogoninfo.ConnectionInfo = crConnectionInfo


'CrTable.ApplyLogOnInfo(crtableLogoninfo)


'Next


Else


MessageBox.Show( "抱歉无数据......"


返回 False


End If


GenerateReport = True


Catch ex As Exception


MessageBox.Show(ex.ToString)


GenerateReport = False


最后


如果 ds 没什么 然后 ds.Dispose()


如果 subDs 没什么 然后 subDs.Dispose()


结束 试试


结束 功能


私人 Sub cmdPreView_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) 句柄 cmdPreView.Click


If GenerateReport()= True 然后


Dim rpt As frmReportWindow


rpt.Text = " Average Analysis"


rpt.crViewer.ReportSource = crReportDocument


rpt.crViewer.DisplayGroupTree = False


rpt.crViewer。缩放(1)


rpt.Show()


End If


结束 Sub


解决方案

你好
这不是Crystal Reports问题的正确形式。这个表格是d iscuss code performance&使用VSTS中的高级开发工具进行安全性,包括静态和动态分析,代码分析和单元测试。


您应该检查 http://msdn.microsoft.com/newsgroups/ 为您的问题找到正确的新闻组。


谢谢
Brian [MSFT]
Microsoft Developer Support
这个帖子是"原样"提供的。没有保证,也没有授予任何权利。


pls help me

I am using Vs 2005 and crystal report 11.5 when i run the set up and try to view the Crystal report below error  Come .when run this code in my machine it works fine when i run the setup and try view the report then error come. I AM USING XML FOR BINDING DATA WITH CRYSTAL REPORTS. THE CODE IS LIKE THIS

ds.WriteXml(Application.StartupPath & "\Reports\AverageAnalysis.xml")

ds.WriteXmlSchema(Application.StartupPath & "\Reports\AverageAnalysisSchema.xsd")

'#########################################################################################

crReportDocument.Load(Application.StartupPath & "\Reports\rptAverageAnalysis.rpt")

And Error doesnot come in Develpoer machine When i install the setup in th client then error come in the report that bind crystal with xml.And in Another  report that having ado.net connection will works fine.

pls help me

failed  to load database information

error in file:"C:\doument\..\\... .rpt")

pls help its very urgent

code is like

Private Function GenerateReport() As Boolean

Dim ds, subDs As New DataSet

Dim strSql As String

Dim pvCollection As New ParameterValues

Dim pdv As New ParameterDiscreteValue

Dim crtableLogoninfos As New TableLogOnInfos

Dim crtableLogoninfo As New TableLogOnInfo

Dim crConnectionInfo As New ConnectionInfo

Dim CrTables As Tables

Dim CrTable As Table

Dim sqladpt As SqlDataAdapter

Dim strConnection As String

If con.State = ConnectionState.Open Then con.Close()

strConnection = "server=192.3;Database=BM123;User Id=sa;Password=dewe"

con.ConnectionString = strConnection 'ReadXML()

con.Open()

Try

GenerateReport = False

strSql = "SPAvgAnalysisDatewiseLocWise '" & txtLocationCode.Text.Trim & "','" & _

txtTradeCode.Text.Trim & "','" & Format(dtpFromDate.Value, "yyyy/MM/dd") & "','" & _

Format(dtpToDate.Value, "yyyy/MM/dd") & "','S','','','APP'"

sqladpt = New SqlDataAdapter(strSql, con)

sqladpt.Fill(ds)

'########################################################################################

'to generate the report we need xml data and schema file, once the report is generated

'no need to create these files , we can directly bind the dataset to report

If Not ds Is Nothing Then

If ds.Tables(0).Rows.Count = 0 Then

MessageBox.Show("Sorry No Data...")

Return False

End If

ds.WriteXml(Application.StartupPath & "\Reports\AverageAnalysis.xml")

ds.WriteXmlSchema(Application.StartupPath & "\Reports\AverageAnalysisSchema.xsd")

'#########################################################################################

crReportDocument.Load(Application.StartupPath & "\Reports\rptAverageAnalysis.rpt")

'With crConnectionInfo

' .ServerName = "192.168.29.152"

' .DatabaseName = "BMS"

' .UserID = "sa"

' .Password = "gitman"

'End With

'CrTables = crReportDocument.Database.Tables

'For Each CrTable In CrTables

' crtableLogoninfo = CrTable.LogOnInfo

' crtableLogoninfo.ConnectionInfo = crConnectionInfo

' CrTable.ApplyLogOnInfo(crtableLogoninfo)

'Next

Else

MessageBox.Show("Sorry No Data...")

Return False

End If

GenerateReport = True

Catch ex As Exception

MessageBox.Show(ex.ToString)

GenerateReport = False

Finally

If Not ds Is Nothing Then ds.Dispose()

If Not subDs Is Nothing Then subDs.Dispose()

End Try

End Function

Private Sub cmdPreView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPreView.Click

If GenerateReport() = True Then

Dim rpt As New frmReportWindow

rpt.Text = "Average Analysis"

rpt.crViewer.ReportSource = crReportDocument

rpt.crViewer.DisplayGroupTree = False

rpt.crViewer.Zoom(1)

rpt.Show()

End If

End Sub


解决方案

Hello
This is not the correct form for Crystal Reports questions. This form is to discuss code performance & security using the advanced development tools in VSTS including static and dynamic analysis, code profiling, and unit testing.

You should check http://msdn.microsoft.com/newsgroups/ to find the correct newsgroup for your issue.

Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.


这篇关于在vb.net中的crystal report中绑定xml时无法加载数据库信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆