Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003

    Red face Unanswered: Changing crystal report datasource at runtime

    Hi all, i am developing a software which using 2 databases. so i want to change the database of report at runtime. i am using crystal report activex designer runtime and design time library. i want to change the

    'set the database to use for this report
    For Each objDatabaseTable In Me.Database.Tables
    objDatabaseTable.Location = App.Path & "\GramCommon.mdb"
    objDatabaseTable.SetSessionInfo "Admin", Chr(10) & "PASSWORD"
    Next objDatabaseTable
    Dim sql As String
    sql = "sElect * from Certificate"
    Set adoRs = CreateObject("adodb.recordset")
    adoRs.Open sql, "Provider=Microsoft.Jet.OLEDB.4.0;Password=''; Data Source=" & App.Path & "\gramcommon.mdb;Persist Security Info=false", adOpenKeyset, adLockBatchOptimistic
    Me.Database.SetDataSource adoRs
    'MsgBox adoRs.ActiveConnection
    Me.Database.AddADOCommand adoRs.ActiveConnection, adoRs.ActiveCommand

    i m using this sort of coding, i tried lot, it gives no error but it gives data of the database which was used while design time of report.

    pl. help to get database changed at runtime, if anybody knows.

    thanks in advance.

  2. #2
    Join Date
    May 2004

    Changing cystal report datasource at runtime


    The following code will code very will in the standalone crystalreport. but it failed in RDC environment. I don't know which type you develop.

    Dim CrxApp As New CRAXDRT.Application
    Dim CrxRpt As CRAXDRT.Report

    Private Sub Form_Load()
    Set CrxRpt = CrxApp.OpenReport(App.Path & "\Data\report1.rpt")
    CrxRpt.Database.Tables(1).SetLogOnInfo sName, dbname, "", ""
    'Sets the location for the first table in the report to the Access database. If the report has
    'more than one table the same location will propagate through all of the tables.
    'You can set a new location for each table individually based on it's index in the Tables collection.

    CrxRpt.Database.Tables(1).Location = "Your Table Name"
    CRViewer1.ReportSource = CrxRpt
    End Sub



  3. #3
    Join Date
    Apr 2004

    Angry What kind of answer is that?

    I mean, if you do not have a clear answer I do not know why you dare to post a response.

    I am looking for a solution about this and whatever the last guy wrote is totally useless, what did you try to say?

  4. #4
    Join Date
    Apr 2002
    Toronto, Canada
    al (if that's your real name) what are you griping about

    the thread is five years old and you expect him to come back and clarify what he said?

    i mean, if you don't have a specific question, i do not know why you dare to post a response | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2009


    YourCRAXDRT.Database.SetDataSource (data,datatag,tablenumber)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts