Skip to Content
0
Former Member
Dec 02, 2009 at 10:40 PM

Crystal Report 2008 DataSource binding

29 Views

Hi,

I have VS2008 webservice which is used to generate report. I am using CR2008 version of crystal report. While creating the report template I specified the development database and now going forward I am trying to set the database source through code and this datasource is specified in the web.config. Issue is reports are not using the datasource that I am setting up at runtime it continues to use the one that is saved in template...

I am using the following code:

protected void logonReport(string dbServerName, string dbName,

string dbUserId, string dbPwd)

{

ConnectionInfo connInfo = null;

TableLogOnInfo tblLogonInfo = null;

Tables tbls = null;

try

{

connInfo = new ConnectionInfo();

connInfo.ServerName = dbServerName;

connInfo.DatabaseName = dbName; //not used for Oracle

connInfo.UserID = dbUserId;

connInfo.Password = dbPwd;

tbls = this._crReport.Database.Tables;

foreach (Table tbl in tbls)

{

tblLogonInfo = tbl.LogOnInfo;

tblLogonInfo.ConnectionInfo = connInfo;

tbl.ApplyLogOnInfo(tblLogonInfo);

}

}

catch (Exception ex)

{

throw ex;

}

finally

{

if (connInfo != null) connInfo = null;

}

}

Please help.

Thanks

kajal