如果是ADO方法连接,程序端如何控制???
可否在程序端设置连接信息。

解决方案 »

  1.   

    在程序中用AddADOCommand方法给报表添加数据源,再用SetUnboundFieldSource方法给unbound field设置字段源。
    下面是我程序中的一段:    dim cnn as new adodb.connection
        dim command as new adodb.command    cnn.open "Provider=Microsoft.Jet.OLEDB.4.0;" _
                & "Data Source=c:\db.mdb;" _    <-----此处路径可更改
                & "Persist Security Info=False"
        '建立一个新的command
        Set command.ActiveConnection = cnn
        command.CommandText = "temp_rpt"
        command.CommandType = adCmdTable
        
        '设置报表的数据源
        m_Report.Database.AddADOCommand cnn, command
        
        '绑定字段
        With m_Report
            .ProjectNumber.SetUnboundFieldSource "{ado.project number}"
            .ProjectName.SetUnboundFieldSource "{ado.project name}"
        End With
        
        Me.CRViewer1.ReportSource = m_Report
      

  2.   

    那么如何控制.rpt文件的数据连接呢???
      

  3.   

    CryOrderReport.Database.LogOnServer "pdsodbc.dll", "taihuasql", "taihua", strUid, strPwd
      

  4.   

    set conn=new adodb.connectoin
      conn.open "连接mdb文件“
      set rs=conn.execute("select...")
      set report=Application1.OpenReport(reppath,crOpenReportByTempCopy)
      Report.DiscardSavedData
      report.database.table(1).setdatasource rs