Results 1 to 2 of 2

Thread: how to change DB connection at runtime for CR using VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Posts
    5

    Question how to change DB connection at runtime for CR using VB

    Hi,

    i have 2 MSSQL DBs.
    im using DSN name to connect MSSQL DB to generate the report. for example, i have designed a report CR1 from the DB using dsn, named DSN1 which refers
    the DB named Master1.

    but now i want to connect the same report CR1 in a another dsn name called as
    DSN2 which refers MSSQL DB named as Master2.
    (because the both DB's have the same table, but i want the report to print from another DB's table. )

    but at runtime if i do the coding from vb application like,

    crystalreport1.connect = "DSN=DSN1"

    (this coding works if the dsn name as DSN1)

    its giving error msg like "error detected by database dll".

    How could i make the data connectivity at runtime to point the different dsn name ie, DSN2. (consider i design the report manually at design mode of CR and connect the DB thru DSN ie, DSN1 refers Master1 DB and call it in vb application at runtime.)

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Create an ADO connection in CR. Then you can use ADO in VB to
    connect to any db and switch at run time. You can even create
    recordsets to pass as the recordsource for the report over and
    over again.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width