Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I'm encountering what must be a fairly common issue. I want to set the path of my reports database through code, though I could not find a direct way of doing so. I found a link to this page through this forum, and its' helped somewhat:

http://support.crystaldecisions.com/library/kbase/articles/c2010490.asp

 

One problem still remains, however... in my report, I created some queries that are essential to what I need. When I set the database path as the above article mentions, it works except for those cases where I use these queries. In those cases, I get this error that it can't find table "Command"... there is no table Command, that's just the way Crystal Reports calls those saved queries, it seems.

 

public sub ShowReport(report_in as Object)

 

 

Dim crTables As Tables

Dim crTable As Table

 

crTables = report_in.Database.Tables

 

For Each crTable In crTables

If crTable.Location <> "Command" Then

MsgBox(crTable.Location)

 

crTable.Location = myPath

End If

Next

 

crvViewer.ReportSource = report_in

 

end sub

  • Moderators
Posted

Here's the way to query...

 

report_in.RecordSelectionFormula = "{myTable.myColumn} = " & SomeVar

 

Also, You shouldn't have to declare it as OBJECT, you can declare it as ReportDocument....

 

public sub ShowReport(report_in as ReportDocument)

Visit...Bassic Software
Posted

Okay, I got it... you need to set the LoginInfo property to something else.....

 

For anyone else encountering a similar problem, here's my code.

 

Dim crTables As Tables

Dim crTable As Table

Dim sqlUnionQuery As String

 

Dim dbLogonInfo As New CrystalDecisions.shared.TableLogOnInfo

 

dbLogonInfo.ConnectionInfo.ServerName = connectDB.getDBPath

 

crTables = report_in.database.tables

 

For Each crTable In crTables

crTable.ApplyLogOnInfo(dbLogonInfo)

Next

 

crvViewer.ReportSource = report_in

 

Me.ShowDialog()

Posted

I used the RecordSelectionFormula for filtering, but that is not quite the type of query I needed. I actually had a very long Union Query which I needed to use as the report source.

 

Anyway, everything works fine now.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...