cancel
Showing results for 
Search instead for 
Did you mean: 

Change database for stored proc

Former Member
0 Kudos

Hi,

I have a report which is bind with a stored proc (sp). I know how to change the server and database for the report but the report's database stay the same

Is it possible to change the database for the stored proc (catalogue) ???

(i'm using C#)

Thank you in advance

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this code


ConnectionInfo crConnectionInfo = new ConnectionInfo();

crConnectionInfo.ServerName = "SERVER";
crConnectionInfo.DatabaseName = "DATABASE";
crConnectionInfo.UserID = "USERID";
crConnectionInfo.Password = "PASSWORD";

// Use a loop to go through all the tables in the main report
foreach(Table crTable in crReportDocument.Database.Tables)
{
	// Get the TableLogOnInfo from the Table and then set the new
	// ConnectionInfo values.
	TableLogOnInfo crLogOnInfo = crTable.LogOnInfo;
	crLogOnInfo.ConnectionInfo = crConnectionInfo;

	// Apply the TableLogOnInfo
	crTable.ApplyLogOnInfo(crLogOnInfo);
			
	// Set the location of the database. This value will vary from		// database to database.
	crTable.Location = crTable.Location;
}

Hope this will help!!

Amit

Answers (3)

Answers (3)

Former Member
0 Kudos

hi,

I have always a "COMException" on the line. But my aim is possible directly in CR

Configuration :

- VSS 2008

- Sybase

- CR XI

I tryed

 TableLogOnInfo LogInfo = new TableLogOnInfo();
            int i = mReport.Database.Tables.Count;
            LogInfo.ConnectionInfo.ServerName="ISAIN_DEV";
            LogInfo.ConnectionInfo.UserID="";
            LogInfo.ConnectionInfo.Password="";
            LogInfo.ConnectionInfo.DatabaseName="espagne";
            for (int j = 0; j < i-1; j++)
			{
			    mReport.Database.Tables[j].ApplyLogOnInfo(LogInfo);
			}

I just arrive to show the report empty in the CrystalReportViewer...

Thank you for your help

Edited by: koyot3 on Mar 19, 2009 8:31 AM

0 Kudos

Sybase requires a user name and password to be entered.

Add them to your code and test again. If you add a Try/Catch in your app it will likely return with invalid logon credentials error. Or something like that.

Thank you

Don

Former Member
0 Kudos

for my example, i don't write my login and password

in my code, fields are not empty ....

0 Kudos

and what error do you get if you catch the exception?

Former Member
0 Kudos

i catch anything....

the report is loaded, but empty.....

Former Member
0 Kudos

Hi,

One more point I have noticed that you are using VS 2008 and CR XI, if yse, then would like to inform that VS 2008 is not compatible with CR XI.

VS 2008 is compatible with CR 2008 SP0 and the CR which bundles with it (CR 10.5).

Sincerely,

Amit

0 Kudos

Please clarify:

"i catch anything...."

Does this mean you have try/catch in your code? If you add the try/catch to just the logon routine does that capture the error?

Also, is ISAIN_DEV your server name or the ODBC DSN?

Have you verified the report and logon info youa re setting in code works in CR DEsigner also?

Former Member
0 Kudos

Please let us know if desired functionality is possible through the CR Designer through the 'Set Datasource Location | Update ' option

Former Member
0 Kudos

thank you for your answer but it doesn't work

i have a ComException on

crTable.ApplyLogOnInfo(crLogOnInfo)

"not valid pointer"

Former Member
0 Kudos

Hi;

Can you provide the exact error you are getting, as well as the type & version of the database you are connecting to, and the version of Crystal Reports you are using.

Regards,

Jonathan