cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect CrystalDecisions.CrystalReports.Engine.Table.Location

baray_nawab
Explorer
0 Kudos

Hi All,

I'm doing a project where my report developer team is developing reports in Crystal reports XI.

This report use oledb provider to connect to sql server 2000.

I have tables name like

"abcowner.xyztable"

"pqrowner.xyztable"

so same table in different owner/schema.

Crystal report is using "pqrowner.xyztable" and it runs fine in crystal report.

I'm have embedded this report in asp.net 3.5 and using 11.5.37.0 runtime. When this report is run in asp.net application using

CrystalDecisions.CrystalReports.Engine.ReportDocument() , it's using table in different schema i.e. "abcowner.xyztable".

I have to manually change the location of the table to point to correct owner. I can't fix like this becuase the application wouldn't know which owner/schema to pick.

foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)

{

crTableLogonInfo = crTable.LogOnInfo;

crTableLogonInfo.ConnectionInfo = crConnectionInfo;

string strLocation = crConnectionInfo.DatabaseName + "SCHEMA/OWNER." + crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1);

crTable.ApplyLogOnInfo(crTableLogonInfo);

crTable.Location = strLocation;

}

Any suggestion ?

Thanks

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

Simple answer, if you don't know how is CR supposed to know which schema to use? CR will use the one it has saved in the RPT file.

You'll have to code in for the user to select which one to use, someone has to tell your app which schema to use, either user interface or a config file.

Thank you

Don

baray_nawab
Explorer
0 Kudos

Don,

CR XI is using the one it has saved in the RPT file. but running this RPT using ReportDocument is using the wrong schema even thought RPT has correct schema.

Thanks

Adam_Stone
Active Contributor
0 Kudos

If you don't pass logon info to the report through code, instead let the viewer prompt, does this work correctly?

Also, in the designer, you can set a overidden fully qualified table name, try that.

baray_nawab
Explorer
0 Kudos

Adam,

If I use crystalreportviewer control then It works fine but when I used ReportDocument then it's picking the wrong schema.

Thanks

Adam_Stone
Active Contributor
0 Kudos

So, what you are saying is, if you use the ReportDocument to load the report and pass that to the viewer and let it prompt for database logon it fails? Or is it when you touch the database information in your code that it then fails?

baray_nawab
Explorer
0 Kudos

Adam,

I'm not using crystalreportview control.

Just Report document, load the report, pass the parameters , provide connection info and then export to pdf.

Thanks

Edited by: baraynawab on May 20, 2011 6:27 PM

former_member183750
Active Contributor
0 Kudos

One thing I'd do 1st is make sure you are on [SP 6|https://smpdl.sap-ag.de/~sapidp/012002523100015859952009E/crxir2win_sp6.exe]. Eventually you'll need the SP 6 runtime:

CR XI r2 (SP6) MSM

https://smpdl.sap-ag.de/~sapidp/012002523100000634042010E/crxir2sp6_net_mm.zip

CR XI r2 (SP6) MSI

https://smpdl.sap-ag.de/~sapidp/012002523100000633302010E/crxir2sp6_net_si.zip

Perhaps using the InProc RAS SDK will be better also. See KB [1553921 - Is there a utility that would help in writing database logon code?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333533353333333933323331%7D.do].

- Ludek

baray_nawab
Explorer
0 Kudos

Yes I'm using sp6. Version=11.5.3700.0

baray_nawab
Explorer
0 Kudos

Adam,

I edited the Overridden qualified table Name to refelct as catalog.owner.tablename.

But still , report document is picking the wrong owner unless i manually change the location.

Thanks

Answers (1)

Answers (1)

Adam_Stone
Active Contributor
0 Kudos

How are you changing it to begin with, and describe what you mean by manually change the location.

baray_nawab
Explorer
0 Kudos

Adam,

I opened the RPT using CR IX then went to Databse -> Set DataSourceLocation then drill down the properties of the each table, right click the overridden qualified table name properite and typed in dbname.owner.tablename (for ex: northwind.abcowner.xyztable)

This is what i'm doing in code

ReportDocument crDoc = new ReportDocument();

crDoc.Load(strPath);

foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)

{

crTableLogonInfo = crTable.LogOnInfo;

crTableLogonInfo.ConnectionInfo = crConnectionInfo;

crTable.ApplyLogOnInfo(crTableLogonInfo);

If i comment this two lines, then it's picking the "pqrowner" . I have to manually set Location to point to "abcowner" which is picked correctly if I just run under CR IX or crystalreportview control

string strLocation = crConnectionInfo.DatabaseName + ".abcowner." + crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1);

crTable.Location = strLocation;

}

crDoc.ExportToDisk(ExportFormatType.PortableDocFormat, tmpInputFilePath);

Adam_Stone
Active Contributor
0 Kudos

Are you trying to change the server/database name at runtime, or are you just wanting to pass user name and password?

baray_nawab
Explorer
0 Kudos

Adam,

just wanting to pass user name and password

Thanks

Adam_Stone
Active Contributor
0 Kudos

Try calling ReportDocument.SetDatabaseLogon("username", "password")

baray_nawab
Explorer
0 Kudos

Adam,

It's working if I just pass username and password.

But when this web app is moved to PRODUCTION server, I have to change server name and database name also to run against production database server.

Thanks

baray_nawab
Explorer
0 Kudos

Adam,

Is there any other method i need to use to pass server name , database , username and password

Thanks

Adam_Stone
Active Contributor
0 Kudos

I would suggest looking at Ludek's reply about using the InProc RAS SDK.