Skip to Content
0
Former Member
Jul 18, 2011 at 08:37 AM

Database Logon Failed which created by Crystal Report 2008

39 Views

this time i meet the famous error again which is database logon failed.

i created a crystal report 2008 starting from blank report, then connect with odbc

i use 2008 method

objRpt.SetDatabaseLogon(db_username, db_password, odbc_name, database_name);

2008 method will get database logon failed even set database location and verify database again

then i use 8.5 method and try again for 2008 report. it said field name is unknown for one of formula

then i drag field again for formula and set database location and verify database again

it said the same error.

then i uninstall 8.5 crytal report software in window 7 deployment machine, and do above again, it said the same error

//'Create a new Stored Procedure Table to replace the reports current table.

CrystalDecisions.ReportAppServer.DataDefModel.Procedure boTable = new CrystalDecisions.ReportAppServer.DataDefModel.Procedure();

//'boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object

PropertyBag boMainPropertyBag = new PropertyBag();

//'boInnerPropertyBag: These hold the attributes for the QE_LogonProperties

//'In the main property bag (boMainPropertyBag)

PropertyBag boInnerPropertyBag = new PropertyBag();

//'Set the attributes for the boInnerPropertyBag

boInnerPropertyBag.Add("Connect Timeout", "15");

//boInnerPropertyBag.Add("Data Source", "MyDataSource");

boInnerPropertyBag.Add("Data Source", "10.1.1.191");

boInnerPropertyBag.Add("DataTypeCompatibility", "0");

boInnerPropertyBag.Add("General Timeout", "0");

//boInnerPropertyBag.Add("Initial Catalog", "MyCatalog");

boInnerPropertyBag.Add("Initial Catalog", database_name);

boInnerPropertyBag.Add("Integrated Security", "False");

boInnerPropertyBag.Add("Locale Identifier", "1033");

boInnerPropertyBag.Add("MARS Connection", "0");

//boInnerPropertyBag.Add("OLE DB Services", "-5");

//boInnerPropertyBag.Add("ODBC", "-5");

boInnerPropertyBag.Add("ODBC", "Cheque");

boInnerPropertyBag.Add("Provider", "SQLNCLI");

boInnerPropertyBag.Add("Tag with column collation when possible", "0");

boInnerPropertyBag.Add("Trust Server Certificate", "0");

boInnerPropertyBag.Add("Use Encryption for Data", "0");

//'Set the attributes for the boMainPropertyBag

boMainPropertyBag.Add("Database DLL", "crdb_ado.dll");

//boMainPropertyBag.Add("Database DLL", "p2sodbc.dll");

//boMainPropertyBag.Add("QE_DatabaseName", "VEPILOT");

boMainPropertyBag.Add("QE_DatabaseName", database_name);

//boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)");

boMainPropertyBag.Add("QE_DatabaseType", "ODBC");

//'Add the QE_LogonProperties we set in the boInnerPropertyBag Object

boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);

boMainPropertyBag.Add("QE_ServerDescription", "MyServer");

boMainPropertyBag.Add("QE_SQLDB", "True");

boMainPropertyBag.Add("SSO Enabled", "False");

//'Create a new ConnectionInfo object

CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();

//'Pass the database properties to a connection info object

boConnectionInfo.Attributes = boMainPropertyBag;

//'Set the connection kind

boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;

//'*EDIT* Set the User Name and Password if required.

boConnectionInfo.UserName = db_username;

boConnectionInfo.Password = db_password;

//'Pass the connection information to the table

boTable.ConnectionInfo = boConnectionInfo;

CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables = objRpt.ReportClientDocument.DatabaseController.Database.Tables;

CrystalDecisions.CrystalReports.Engine.Tables tables = objRpt.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

{

if (!string.IsNullOrEmpty(table.Name))

{

//boTable.Name = table.Name;

//boTable.QualifiedName = database_name + ".dbo." + table.Name;

//boTable.Alias = table.Name;

boTable.Name = "sp_ChequeIssueDetRpt";

boTable.QualifiedName = database_name + ".dbo.sp_ChequeIssueDetRpt";

boTable.Alias = "sp_ChequeIssueDetRpt";

objRpt.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0], boTable);

}

}

objRpt.VerifyDatabase();

http://sourceforge.net/projects/aspchequesprint/files/ChequeIssueDet.rpt/download