VB   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了database – 在运行时设置Crystal Report数据源大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在创建Crystal Report时,我显然建立了一个用于开发的数据库和服务器连接.

我现在想在VB应用程序中做的是动态设置数据库和服务器名称以用于报告.我将这些值作为字符串varServer和varDatabase.@H_772_2@

有谁知道怎么做这个?@H_772_2@

提前致谢.@H_772_2@

P.S我尝试了几种在线解决方案,但是我遇到了VB6问题.@H_772_2@

This link拥有您想要了解的所有信息.

更新:这是使用sqL Server进行集成身份验证的最低工作示例.您应该使用表对象的ConnectionProperties来设置连接参数.@H_772_2@

Dim app As New CRAXDDRT.Application
Dim rpt As CRAXDDRT.Report
Dim tbl As CRAXDDRT.DatabaseTable
Dim tbls As CRAXDDRT.DatabaseTables

Set rpt = app.openReport("C:\report\repotest.rpt")

For Each tbl In rpt.Database.Tables
    tbl.ConnectionProperties.deleteAll
    tbl.ConnectionProperties.Add "Provider","SQLOLEDB"
    tbl.ConnectionProperties.Add "Data source","localhost"
    tbl.ConnectionProperties.Add "Initial Catalog","testdb"
    tbl.ConnectionProperties.Add "Integrated Security","True"   ' cut for sql authentication
    'tbl.ConnectionProperties.Add "User Id","myuser"   ' add for sql authentication
    'tbl.ConnectionProperties.Add "password","mypass"  ' add for sql authentication
Next tbl

'This removes the scheR_935_11845@a from the Database Table's LOCATIOn property.
Set tbls = rpt.Database.Tables
For Each tbl In tbls
    With tbl
        .LOCATIOn = .Name
    End With
Next

'View the report
Viewer.Reportsource = rpt
Viewer.ViewReport

大佬总结

以上是大佬教程为你收集整理的database – 在运行时设置Crystal Report数据源全部内容,希望文章能够帮你解决database – 在运行时设置Crystal Report数据源所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。