Database connection Crystal Reports doesn´t works!!!
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = cryRpt.Database.Tables ;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
but this Works fine!
foreach (Table crTable in objRpt.Database.Tables)
{
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo = objRpt.Database.Tables[crTable.Name].LogOnInfo;
logOnInfo.ConnectionInfo.ServerName = server.Trim();
logOnInfo.ConnectionInfo.DatabaseName = database.Trim();
logOnInfo.ConnectionInfo.UserID = username;
logOnInfo.ConnectionInfo.Password = password;
objRpt.Database.Tables[crTable.Name].ApplyLogOnInfo(logOnInfo);
}
No hay comentarios:
Publicar un comentario