tags:

views:

270

answers:

1

I`m having problems between two servers, wich use differente odbc dsn.

My apps work great but crystal reports uses the original odbc connection, how can I fix this?

I'm thinking of using the same connection string in the web.config, but I don't know how.

found this but is too confusing for me

thanks,

+1  A: 

You can't use a connection string in the same way you can with an ado.net connection. However, you can certainly use values from the web.config to specify the connection info. Create an instance of the ConnectionInfo class and set the ServerName, DatabaseName, UserID, and Password properties. Then attach it to each of the tables in the report:

ConnectionInfo reportConnectionInfo = new ConnectionInfo();
reportConnectionInfo.ServerName = ConfigurationManager.AppSetting["ServerName"];
reportConnectionInfo.DatabaseName = ...;
reportConnectionInfo.UserID = ...;
reportConnectionInfo.Password = ...;

foreach (Table table in reportDocument.Database.Tables) {
  table.LogOnInfo.ConnectionInfo = reportConnectionInfo;
}

If you try to use this suggestion, beware of my sloppy typing...

Ray
is there a way to use a connection string instead?
sergiogx
I am not aware of any way to do that
Ray
found out that I can set servername as the odbc dsn, it kind of worked, but I still get an error, I think this is something else. thanks
sergiogx