private void SetTableLogin(CrystalDecisions.CrystalReports.Engine.Table table) { CrystalDecisions.Shared.TableLogOnInfo tliCurrent = table.LogOnInfo; string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; var builder = new SqlConnectionStringBuilder(connectionString); //var dataSource = builder.DataSource; tliCurrent.ConnectionInfo.UserID = builder.UserID; //"sa"; tliCurrent.ConnectionInfo.Password = builder.Password; //"aziz123"; tliCurrent.ConnectionInfo.DatabaseName = builder.InitialCatalog; //"Restaurant_DB"; //Database is not needed for Oracle & MS Access tliCurrent.ConnectionInfo.ServerName = builder.DataSource; //"NIMBLE\\SQL2K8"; table.ApplyLogOnInfo(tliCurrent); }
/// <summary> /// Assign a <see cref="ConnectionInfo"/> to a <see cref="CrystalDecisions.CrystalReports.Engine.Table"/> object /// </summary> /// <param name="table">Table to which the connection is to be assigned</param> /// <param name="connection">Connection to the database.</param> private static void AssignTableConnection(CrystalDecisions.CrystalReports.Engine.Table table, ConnectionInfo connection) { // Cache the logon info block TableLogOnInfo logOnInfo = table.LogOnInfo; // Set the connection logOnInfo.ConnectionInfo = connection; // Apply the connection to the table! table.ApplyLogOnInfo(logOnInfo); }