Crystal report web service, change database/server location?

S

Sam Fisher

Hi,
I have a crystal reports hosted on the IIS as web service. Everything works fine except that I can not access the database other than the one on which the report originally created.

I am using the LogOnInfo of the viewer to set the user name, password, database location and server names
But the following kb article says 'When using the viewer's LogOnInfo collection, you are unable to change the database/table information for a report web service. The LogOnInfo connection will only allow the report web service to use the database/table information that was used to design the report'


http://support.businessobjects.com/library/kbase/articles/c2014056.asp

so question is 'How do I programmatically change the server and the database on the fly?'

Thanks for any suggestions

Sam
 
Z

ZRexRider

Something similar to the following works for me.

Search help or Google for SetLogOnInfo


Private SUB(byref crxReport as report, byval strServerName as String,
byval strDatabase as string)
Dim n as Integer
' Loop through all tables in report and update their connection
parameters
'
-----------------------------------------------------------------------------
For n = 1 To crxReport.Database.Tables.Count
crxReport.Database.Tables.Item(n).SetLogOnInfo _
strServerName, _
strDatabase
Next n
End Sub
 
B

Brian Bischof

Two things to note here. First is that you actually CAN make changes to the
database connection using the Viewer control via a web service. Use the
LogonInfo property of the viewer control. Secondly, anytime you change the
server name and database name then you also have to reset the TableName
property back to just the table name. If you examine the TableName property
in debug mode then you'll notice that the database name is embedded in this
string and thus needs to be reset.

Secondly, you can make changes to a report using the ReportObject on the
server by doing so within CreateReport() event (part of the hidden .asmx.vb
file). This isn't really documented anywhere, but I go into details in
Chapter 18 of my book. Anything you do to the ReportObject normally can be
done with a web service. You just have to do it within the CreateReport()
event.

HTH,

Brian Bischof
www.CrystalReportsBook.com
 
S

Sam Fisher

Thanks Brian Bischof for the valueable information.

Yes now i am using the LogOnInfo property of viewer control to set the
server and the database locations.
But when i check the table names i always see the one table in the list, I
do not see the database name embeded with the table name as you explained

Here is what i am doing...


CrystalReportViewer1.ReportSource =
http://Server/ReportService/repservice.asmx

Dim tli As CrystalDecisions.Shared.TableLogOnInfo
For Each tli In CrystalReportViewer1.LogOnInfo '<Here i always see only
one table in the collection irrspective of number of table i actually have
in the report
tli.ConnectionInfo.Password = "password"
tli.ConnectionInfo.UserID = "sa"
tli.ConnectionInfo.ServerName = "ServerName"
tli.ConnectionInfo.DatabaseName = "DatabaseName"
Next
CrystalReportViewer1.Visible = True

Still the problem is same it always querris the database on which i created
the report

Any thoughts

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top