Link to home
Start Free TrialLog in
Avatar of mystery001
mystery001

asked on

Database Source Location and VB

hi,

CR9 dev & Visual Basic 6

I want to change the database source location of a CR9 report with VB without change the location in the report file...

Thanks
Avatar of Mike McCracken
Mike McCracken

Avatar of mystery001

ASKER

In fact, it doesn't help me because the document is for CR8 and CR8.5. But, i've got CR9 and it's not the same methods.

Thanks anyway. :-)
What code are you trying to use?

mlmcc
This is my code
-----------------------------------------------------------
'DECLARATION
Dim UserID As String
Dim Pwd As String
Dim v_seq As String
Dim Source As String
Dim DBsource As String

'Affectation des variables
UserID = "userID"
Pwd = "password"
Base = "baserisc"
v_seq = T_seq.Text
DBsource = "DSN=" & Base & ";;User ID=" & UserID & ";;Password=" & Pwd
   
    'OUVERTURE DU FICHER
    Set CrxRpt = CrxApp.OpenReport("C:\ccm\prc\etats CR\cclt_ess.rpt")

    'CONNEXION BASE DE DONNEE
    CrxRpt.Database.Tables(1).ConnectBufferString = DBsource
   
    'ENVOI DES VALEURS DES PARAMETRES
    CrxRpt.ParameterFields.GetItemByName("v_seq").ClearCurrentValueAndRange
    CrxRpt.ParameterFields.GetItemByName("v_seq").AddCurrentValue v_seq
    CrxRpt.ParameterFields.GetItemByName("indice_langue").ClearCurrentValueAndRange
    CrxRpt.ParameterFields.GetItemByName("indice_langue").AddCurrentValue 20000
    CrxRpt.PaperSize = 155 'us LETTER
   
    F_CRViewer.CRViewer91.ReportSource = CrxRpt 'Définit le fichier à ouvrir dans le contrôle
    F_CRViewer.CRViewer91.ViewReport 'Affiche la rapport
    F_CRViewer.CRViewer91.DisplayGroupTree = False
    F_CRViewer.CRViewer91.Zoom (110)
    F_CRViewer.CRViewer91.DisplayTabs = False
    F_CRViewer.CRViewer91.EnableCloseButton = False
    F_CRViewer.CRViewer91.EnableGroupTree = False
    F_CRViewer.Show

-----------------------------------------------------------

With this method i can connect to my database "baserisc" ("baserisc" being the database set in cclt_ess.rpt).
The problem is that, in my case, i have 4 differents databases (baserisc, baserisd, baserish, baserise) and i want to be able to connect to the differents databases (all the databases have the same structure).
And i don't want to create 4 files with a different database for each file. So, i have to do that in VB !

Thanks to help me. :-)
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial