Question : How to use trusted connection: CR 8.5, VB6, SQL Server

How can I programatically connect to my database using a trusted connection?  This DOES work:

  Dim CrxReport As CRAXDRT.Report
  CrxReport.Database.Tables.Item(1).SetLogOnInfo "MyServer", "MyDB", "MySQLUserID", "MyPassword"

but what is the equivalent for a TRUSTED CONNECTION to SQL Server?  

I tried this:
  CrxReport.Database.Tables.Item(1).SetLogOnInfo "MyServer", "MyDB",null,null
and this:
  CrxReport.Database.Tables.Item(1).SetLogOnInfo "MyServer", "MyDB","",""

but no luck.  Is there some other method I should be using?

Thx in advance!

Answer : How to use trusted connection: CR 8.5, VB6, SQL Server

Trusted connection is just that.  I have all my reports setup that way and have no need to supply any connection or table information.

Here is the code I use

Option Explicit
    Dim crApp As CRAXDRT.Application
    Dim crRpt As CRAXDRT.Report

Public Sub crPreview_Report( )
'
'   Check if report is already in use
'
    If IsObject(crRpt) Then
       Set crRpt = Nothing
    End If

'
'   Open report
'
    Set crApp = New CRAXDRT.Application

    Set crRpt = crApp.OpenReport("FULL REPORT PATH", 1)
   
    crRpt.RecordSelectionFormula = "{TableName.DepartmentID} = 6"


'
'   Set flags for CRViewer
'
    crRpt.MorePrintEngineErrorMessages = False
    crRpt.EnableParameterPrompting = False
    crRpt.DiscardSavedData
   
'
' Set the viewer's report source to the Report object
'
    Me.rptCRViewer.ReportSource = crRpt
    Me.rptCRViewer.ViewReport
    Me.Show

End Sub

mlmcc
Random Solutions  
 
programming4us programming4us