Crystal Reports problem

B

Brian Henry

I have a bunch of reports in crystal reports.net, i need to basicly run them
on differnt databases depending on which one the user logged into at the
vb.net application start (dev, live, testing)... now the reports are created
at the development level.. so i figured just change the database like you
pass parameters to the report viewer... well.. I cant seem to figure that
one out, but the report alone as an object (ReportDocument object) has a
method SetDataSource which lets you specify the user,pass,database,server
name per report... now my questions are

1) instead of at the report level can i do this at the report viewer level
somehow?

2) how do i use windows authentication with this? it seems to support
user/pass only.. thanks
 
L

Lee Moody

The following is some code provided to me from Crystal
Reports that may help:

Sub SetReportFileLocations(ByRef rpt As ReportDocument)
Dim crConnectionInfo As New ConnectionInfo
With crConnectionInfo
'physical server name (OLE DB) or ODBC DSN
.ServerName = DNSName
' Note: you do not need to set .DatabaseName for
Oracle.
.DatabaseName = DatabaseName
.UserID = LogonUserName
.Password = LogonUserPassword
End With

'Get the table information from the report
Dim crDatabase As Database
crDatabase = rpt.Database

Dim crTables As Tables
crTables = crDatabase.Tables
Dim crtable As Table

'Loop through all tables in the report and apply the
connection
'information for each table.
Dim crTableLogOnInfo As TableLogOnInfo

For Each crtable In crTables
crTableLogOnInfo = crtable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crtable.ApplyLogOnInfo(crTableLogOnInfo)
If crtable.TestConnectivity() Then
' Create fully qualified name by
appending "database.owner." to the table name.
crtable.Location = DatabaseName & ".dbo." +
crtable.Location.Substring(crtable.Location.LastIndexOf
(".") + 1)
Else
MessageBox.Show("Connection Failed attempting to
connect to table: " & DatabaseName & ".dbo." +
crtable.Location.Substring(crtable.Location.LastIndexOf
(".") + 1))
End If
Next
End Sub

-Lee
 
B

Brian Henry

ok but what does SetDatabaseLogon do then? the way MSDN puts it, it sounds
like it should change the database...
 
L

Lee Moody

I have no idea what SetDatabaseLogon does.

-Lee
-----Original Message-----
ok but what does SetDatabaseLogon do then? the way MSDN puts it, it sounds
like it should change the database...





.
 

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