6 database vb6 crystal-reports
在创建Crystal Report时,我显然建立了一个用于开发的数据库和服务器连接.
我现在想在VB应用程序中做的是动态设置数据库和服务器名称以用于报告.我将这些值作为字符串varServer和varDatabase.
有谁知道怎么做这个?
提前致谢.
PS我已经尝试了几种在线解决方案但是我遇到了VB6问题.
此链接包含您想了解的所有信息。
更新:这是与 SQL Server 集成身份验证的最小工作示例。您应该使用表对象的 ConnectionProperties 来设置连接参数。
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 schema 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23472 次 |
| 最近记录: |