Link to home
Start Free TrialLog in
Avatar of aletheia1
aletheia1

asked on

Problem with "Add Command" and Table Location

Hi again,

I created a report, and specified my own query with the option "Add Command".
Everything seems to work within Crystal Report.

But when I try to load my report from the ASP application, I get the error "Error Occurred Reading Records: The table 'myOwner.Command' could not be found."

Because in my ASP page I need to specify:
Table.Location = "myOwner." + Table.Name

How can I avoid this problem? I mean, how can I specify the table location in another way?

Thanks in advance
Avatar of aletheia1
aletheia1

ASKER

Spykair, GJParker... any ideas?
please post the full ASP code used to connect to the db and display the report.

Gary
For inttable = 1 To Session("oRpt").Database.Tables.Count
      Set CryTable = Session("oRpt").Database.Tables.Item(CInt(inttable))
      CryTable.SetLogOnInfo "myDatabase",,"myOwner","myPassword"
      CryTable.Location = "myOwner." + CryTable.Name
Next


I get the error at the last line... because Crystal Report search for "myOwner.Command", that doesn't exist.
If I comment that line, it works... but I need to specify the table location...
Why are you setting the table location ?

If it works without that line then why do you need to try and set it ?

Gary
Because there are different environments, as test and production... so different table owners.
Yes I understand that but seeing as you control the SQL in the Command you don't need to specify the owner in the command and subsequently it's not needed in the ASP Code.

Gary
Actually the whole code is this:

For inttable = 1 To Session("oRpt").Database.Tables.Count
      Set CryTable = Session("oRpt").Database.Tables.Item(CInt(inttable))
      If Request.Cookies("connection")("db") = "prod" Then
            CryTable.SetLogOnInfo "prodDB",,"myOwner1","myPassword"
            CryTable.Location = "myOwner1." + CryTable.Name
    ElseIf Request.Cookies("connection")("db") = "test" Then
            CryTable.SetLogonInfo "testDB",,"myOwner2","myPassword"
            CryTable.Location = "myOwner2." + CryTable.Name
      End If       
Next

I was suggested to do like this in this topic... please take a look:
https://www.experts-exchange.com/questions/20903964/Change-datasource.html
Yes that's the correct way to change the database for reports that ar ecreated using tables and joins. But as this report doesn't use tables you shouldn't need to do that.

Gary
> But as this report doesn't use tables

I don't understand this... why you say that I don't use tables?
I'm also using joins.

SELECT b.codvia, b.codvis, b.datpar, b.datarr, h.lastname AS DIPEND, e.mezzo AS departure, i.mezzo AS arrival, g.mezzo AS mezzo FROM vtab040 a, vtab032 b, vtab014 e, vtab015 f, vtab016 g, tab001 h, vtab014 i WHERE a.codvia = b.codvia AND (a.CODDIP = h.ID AND a.codogg = 1) AND f.mezzo=g.id AND f.codvia = b.codvia AND f.codvia = a.codvia AND e.id(+) = b.departure AND i.id(+) = b.arrival AND TRUNC(datpar) <= NVL(TRUNC(TO_DATE('','dd/mm/yyyy')),TRUNC(TO_DATE('31/12/2999','dd/mm/yyyy'))) AND TRUNC(datarr) >= NVL(TRUNC(TO_DATE('','dd/mm/yyyy')),TRUNC(TO_DATE('01/01/1900','dd/mm/yyyy'))) GROUP BY b.codvia,b.codvis,b.datpar,b.datarr,h.lastname,g.mezzo,e.mezzo,i.description ORDER BY datpar DESC
ASKER CERTIFIED SOLUTION
Avatar of GJParker
GJParker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, now I understand.

Sorry for my hard comprension... Crystal Report is still a mistery for me.

Thank you :-)
At least we got there in the end.

Glad i could help

Gary