2.使用TableLogonInfo
Dim ReportDoc As New ReportDocument()
Dim logonInfo As New TableLogonInfo
Dim table As table
ReportDoc.Load("C:\Rpts\publish.rpt")
For Each table IN ReportDoc.DataBase.Tables
        logonInfo= table.LogonInfo
        with logonInfo.connectioninfo
          .serverName= "Localhost"
          .Databasename= "pubs"
          .UserID= "sa"
          .Password=""
        End With
        table.applyLogonInfo(logonInfo)
next table
Crviewer.reportsource= reportDoc