views:

18

answers:

1

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();
A: 

It's a pain in the neck, eh?

If you and your friends are using the same make and model of database table server, you might try putting an entry in each developer machine hosts file to create a local hostname alias, or if your development data bases are all on your own machines, use localhost.

If you use ODBC, you can all create your own ODBC entries with the same name and use those.

Ollie Jones