cancel
Showing results for 
Search instead for 
Did you mean: 

Migrating from dbase to Access.

11-23-2009 5:48 AM
405 views 4 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hello

I have a crystal report that has dbase database.The report uses 7 dbf tables and have 6 subreports.

I need to migrate the report to Access databases. I have written a below code(dotnet) to migrate it mdb. I am passing each sub report to below method. The issue is, if there are multiple tables in a single sub report, the connection is not setting correctly i.e table.TestConnectivity() is failing. Can you please suggest what can be done here.

bool UpdateConnectionInfoToAccess(ref ReportDocument reportDocument)

{

string path1 =@"C:\Work\Welfare.Procapita\Procapita.Main\XFiles\CRAPI\TestCRAPI\TestCRAPI\report\KJ1BNE.mdb";

try

{

CrystalDecisions.Shared.DbConnectionAttributes dbAttributes = new DbConnectionAttributes();

dbAttributes.Collection.Set("Data Source",path1);

dbAttributes.Collection.Set("Database Type", "Access/Excel(DAO)");

ConnectionInfo CI = new ConnectionInfo();

CI.ServerName = path1;

CI.DatabaseName = path1;

CI.UserID = "";

CI.Password = "";

CI.IntegratedSecurity =false;

CI.LogonProperties.Clear();

CI.Attributes.Collection.Clear();

CI.Attributes.Collection.Set("Database DLL", "crdb_dao.dll");

CI.Attributes.Collection.Set("QE_DatabaseType", "Access/Excel (DAO)");

CI.Attributes.Collection.Set("QE_LogonProperties", dbAttributes);

CI.Attributes.Collection.Set("QE_SQLDB", true);

CI.LogonProperties = dbAttributes.Collection ;

foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDocument.Database.Tables)

{

//*********************************Cache the logon info block

TableLogOnInfo logOnInfo = table.LogOnInfo;

//*************************************Set the connection

logOnInfo.ConnectionInfo = CI;

//******************************Apply the connection to the table!

table.LogOnInfo.ConnectionInfo.LogonProperties.Clear();

table.ApplyLogOnInfo(logOnInfo);

bool tr= table.TestConnectivity(); //test the connectivity with mdb

}

//****************************Verify Database**************************

reportDocument.VerifyDatabase();

}

catch (CrystalDecisions.ReportSource.EnterpriseLogonException exp)

{

MessageBox.Show(exp.Message);

}

return true;

}

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

0 Likes

Moved to .NET SDK forum.

I would try setting location using the Report Designer first and see if any messages pop up. It may be a mapping problem also.

And curious why you are using: catch (CrystalDecisions.ReportSource.EnterpriseLogonException exp)

That function is used to log onto Businessobjects Enterprise and not a reporting database file

Thank you

Don

Former Member
0 Likes

Hello,

Thanks for the response. I agree the exeception catch is invalid. However I was doing some research to know what kind of error the code is generating. I am not using this exception any more.

However, the main issue is if the sub report has mutiliple tables (dbf) and when I am trying to change the connectivity to access database from dbase( which has all the tables) it's failing to set the connectioninfo for a table. Below is the code

void UpdateReportDocument(ref ReportDocument reportDocument)

{

if (reportDocument.Subreports.Count > 0)

{

for (int i = 0; i < reportDocument.Subreports.Count; i++)

{

ReportDocument subreport = reportDocument.Subreports<i>;

UpdateConnectionInfoToAccess(ref subreport);

}

}

}

bool UpdateConnectionInfoToAccess(ref ReportDocument reportDocument)

{

string path1 =@"C:\Work\Welfare.Procapita\Procapita.Main\XFiles\CRAPI\TestCRAPI\TestCRAPI\report\KJ1BNE.mdb";

CrystalDecisions.Shared.DbConnectionAttributes dbAttributes = new DbConnectionAttributes();

dbAttributes.Collection.Set("Data Source",path1);

dbAttributes.Collection.Set("Database Type", "Access/Excel(DAO)");

ConnectionInfo CI = new ConnectionInfo();

CI.ServerName = path1;

CI.DatabaseName = path1;

CI.UserID = "";

CI.Password = "";

CI.IntegratedSecurity =false;

CI.LogonProperties.Clear();

CI.Attributes.Collection.Clear();

CI.Attributes.Collection.Set("Database DLL", "crdb_dao.dll");

CI.Attributes.Collection.Set("QE_DatabaseType", "Access/Excel (DAO)");

CI.Attributes.Collection.Set("QE_LogonProperties", dbAttributes);

CI.Attributes.Collection.Set("QE_SQLDB", true);

CI.LogonProperties = dbAttributes.Collection ;

foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDocument.Database.Tables)

{

//*********************************Cache the logon info block

TableLogOnInfo logOnInfo = table.LogOnInfo;

//*************************************Set the connection

logOnInfo.ConnectionInfo = CI;

//******************************Apply the connection to the table!

table.LogOnInfo.ConnectionInfo.LogonProperties.Clear();

table.ApplyLogOnInfo(logOnInfo);

bool tr= table.TestConnectivity(); //test the connectivity with mdb

}

//****************************Verify Database**************************

reportDocument.VerifyDatabase();

}

I need to know why its happening. If possible a work around for it.

Kamlesh

Former Member
0 Likes

I am using crystal Report v 12.0.0.683 and is using crdb_dao.dll v12.0.0.683.

Answers (1)

Answers (1)

0 Likes

Install the latest patches and test again, SP2 is available now. You were using the original release