Skip to Content
0
Former Member
Nov 08, 2010 at 09:32 AM

CRVS2010 Beta --Can't change the logon information

35 Views

when I use the following code to change the database logon information, after calling method ApplyLogOnInfo, the logon information in each table of ReportDocument can't be changed

void SetReportDBInfo(ref CrystalDecisions.CrystalReports.Engine.Tables a_tbls)

{

DbConnectionStringBuilder dbBuilder = DatabaseHelper.GetSqlConnectionStringBuilder();

SqlConnectionStringBuilder sqlBuilder = null;

if ((sqlBuilder = dbBuilder as SqlConnectionStringBuilder) != null)

{

foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in a_tbls)

{

CrystalDecisions.Shared.TableLogOnInfo logInfo = (TableLogOnInfo)tbl.LogOnInfo.Clone();

logInfo.ConnectionInfo.LogonProperties.Clear();

logInfo.ConnectionInfo.AllowCustomConnection = true;

logInfo.ConnectionInfo.ServerName = sqlBuilder.DataSource;

logInfo.ConnectionInfo.DatabaseName = sqlBuilder.InitialCatalog;

logInfo.ConnectionInfo.UserID = sqlBuilder.UserID;

logInfo.ConnectionInfo.Password = sqlBuilder.Password;

tbl.ApplyLogOnInfo(logInfo);

bool ret = tbl.TestConnectivity();

}

}

}

the result of method TestConnectivity is aslo false. please tell me why, thanks! By the way I use CRVS2010 Beta2 and VS2010 and I set up the reportsource of CrystalViewer in Page_Load, and the code is:

ReportDocument rd = new ReportDocument();

rd.Load(Server.MapPath(path));

CrystalDecisions.CrystalReports.Engine.Tables tbls = rd.Database.Tables;

SetReportDBInfo(ref tbls);

rd.Refresh();

SPRCrystalReportViewer.ReportSource = rd;