Skip to Content
author's profile photo Former Member
Former Member

Change database for stored proc

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 17, 2009 at 04:42 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 17, 2009 at 04:57 PM

    thank you for your answer but it doesn't work

    i have a ComException on

    crTable.ApplyLogOnInfo(crLogOnInfo)

    "not valid pointer"

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 18, 2009 at 10:44 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 19, 2009 at 07:31 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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?

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.