I'm developing a local app with friends and we're using svn, but we have crystal reports, but it saves the last server used by one of my friends when doing the commit. I tried changing the server programatically using this piece of code, but it didn't work :S
*UPDATE: it seems that the .rpt keeps a history of the server names, and somehow doesn't seem to clear the list, so my friends computer "\sqlexpress" is still there, and I can't seem to clear it :S"
string nombre = WindowsIdentity.GetCurrent().Name.ToString().Split('\\')[1];
ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables ;
//cryRpt.SetDatabaseLogon(string.Empty,string.Empty, nombre + "\\sqlexpress","trupp");
cryRpt.Load(FinalPath);
crConnectionInfo.ServerName = nombre + "\\sqlexpress";
crConnectionInfo.IntegratedSecurity = true;
crConnectionInfo.UserID = string.Empty;
crConnectionInfo.Password = string.Empty;
crConnectionInfo.DatabaseName = "trupp";
CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();