环境:win2000,vb6,crystalv9.2,sqlserver2K在Crystal中采用OLEDB连接数据库,vb6中调用Crystal做成的报表时,老是出现数据库登陆对话框,不知道怎么去除,请各位大侠多多指教,我的VB代码如下:
    
    Dim CryApp As New CRAXDDRT.Application    Dim Report As CRAXDDRT.Report
    
    Set Report = CryApp.OpenReport(App.Path & "\report\SampleBill.rpt")    'adoRS.Open "select top 10 * from answers", cnn1, adOpenDynamic, adLockBatchOptimistic    'Report.Database.SetDataSource adoRS    CRViewer91.ReportSource = Report    CRViewer91.ViewReport 

解决方案 »

  1.   

    参照这个:
    Dim CryApp As New CRAXDDRT.Application   Dim moxAplication As CRAXDRT.Application
       
        Dim moxData  As CRAXDRT.DatabaseTable
        
        Set moxAplication = New CRAXDRT.Application
        Set moxReport = moxAplication.OpenReport("E:\jyc040e1.rpt")
        
        Call moxReport.DiscardSavedData
        
        
        Call moxReport.Database.Tables(2).SetLogOnInfo("aplite2", "", "ct00", "nec")
        '***或者用下面的
    '    For Each moxData In moxReport.Database.Tables
    '        Call moxData.SetLogOnInfo("aplite2", "", "ct00", "nec")
    '    Next
        'SQL
        'moxReport.SQLQueryString = "select * from V_JYC040E"
        'RANGE
        'moxReport.RecordSelectionFormula = "{V_JYC040E111.ZYUCHUYMD}>=20011101 AND {V_JYC040E111.ZYUCHUYMD}<20011201"
        '************************************    CRViewer1.ReportSource = moxReport
        CRViewer1.ViewReport
        CRViewer1.Zoom (100)
        Set moxAplication = Nothing
      

  2.   

    找不到SetLogOnInfo方法, 版本:crystal report9.2  、VB6
      

  3.   

    Crystal8.5中有一方法:        
    cryTrialReport.Database.LogOnServer "pdsodbc.dll", ODBC名, 数据库名,Uid,Pwd
    在9.1肯定也有,加上应该就可以了
    因为Crystal的报表的数据源是自成体系的(相对VB的数据源而言)
      

  4.   

    To 0211997 的兄弟:   你的方法是通过ODBC连接数据库吗?
      

  5.   

    请问下面语句中的 ("aplite2", "", "ct00", "nec") 分别是什么意思,数据库服务器? 登陆用户? 密码?   Call moxReport.Database.Tables(2).SetLogOnInfo("aplite2", "", "ct00", "nec")
      

  6.   

    cryTrialReport.Database.LogOnServerEX "ado", ODBC名, 数据库名,Uid,Pwd,,连接字串以上这个应该可以用作连接SQLServer的了。
      

  7.   

    TO 0755
    Call moxReport.Database.Tables(2).SetLogOnInfo("数据库名", "", "用户名", "密码")
      

  8.   

    请问楼上,
    Tables(2)的"2"是代表什么的?