News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

How To Connect Two Database Connection In Crystal Reports

Started by VelMurugan, Jun 25, 2008, 04:26 PM

Previous topic - Next topic

VelMurugan

Hi [You],

Currently Am working in report modules.

In that module, i am using multiple database. I want to connect Two database in my reports. At runtime i will change the databases according to the reports.

Help me, How to connect two databases in reports at runtime.

Front End : VB.Net 2005
Back End : Sql Server 2005

Help Me.....................

Kalyan

Dear Velu,

I was searching some information from the crystal report support site.

before go that article, check the solution which i give below...

make it use according to your project / product

And I found this article,

http://support.crystaldecisions.com/library/kbase/articles/c2007089.asp

With the same idea, is it mean that there is no way to access two or
more databases from a singal crystal report template?

so, am not sure, try to implement...

to make 2 diff connection to call two database.. i don't how u develop the source, if u tell that the way of source code, i ill help u sure...

check this...

CrystalReport1.LogonInfo(0) = "dsn=DB1; uid=ID; pwd=password"
CrystalReport1.LogonInfo(1) = "dsn=DB2"
CrystalReport1.ReportFileName = "1.rpt"


another method:

and one more thing if it possbile use 2 different database to call in single report.


If u have a report template "itacumens.rpt" requires data from 2 different databases, MSSQL and MSAccess. When u make the connect
individually on each database, they both work very well. However, it isn't make sense to me that I can make 2 connections in the same
CrystalReport object.

Are there any methods to handle this sort of situation? try this code..

Private Sub Command1_Click()
   With CrystalReport1
       
       '* works with SQL server *
     .Connect = "dsn=myLocalSQLDB;uid=myID;pwd=myPassword"    'works
     '.ReportFileName = "C:\Report_SqlSers.rpt"               'works
       
       '* works with MSAccess *
     .Connect = "dsn=myLocalAccessDB"                         'works
     '.ReportFileName = "C:\Report_MSAccess.rpt"              'works
       
       '/* Both */
     .ReportFileName = "C:\Report_both.rpt" 
       'with runtime error, due to re-assign value as the
       'parameter to the connection, I believe?
       
     .WindowHeight = 600
     .WindowWidth = 800
     .Action = 1
       
End With     
End Sub

VelMurugan

Hi Kalyan,

Thanks For ur Help. I Will Try this way and check it And message you later.

Once Again, I Thank You

ganeshbala

Hi Vel

  Check this...
  But i dont know how it works

  try It ..

 
Me.CrystalReportViewer.LogOnInfo.Item(0).ConnectionInfo.ServerName = "MY-COMP"
Me.CrystalReportViewer.LogOnInfo.Item(0).ConnectionInfo.DatabaseName = "NetMania"
Me.CrystalReportViewer.LogOnInfo.Item(0).ConnectionInfo.UserID = "sa"
Me.CrystalReportViewer.LogOnInfo.Item(0).ConnectionInfo.Password = "xxxxxx"


[blink]reference site[/blink]
http://forums.devx.com/showthread.php?t=57193