Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you get "setlocation" to work ? (CR 8.5)

Status
Not open for further replies.

purrepirre

Programmer
Sep 19, 2001
6
SE
I am using CR 8.5

I'm trying to change the database my reports are using from my local SQLServer test-database to the SQLServer at my customer.

In a best case senario this could be done dynamicly in code

The code i have tried so far (see below) seems to do nothing, no error but the reports still use the same db as before.

CODE
///////////////////////////////////
Code:
 Dim CRReport As CRAXDRT.Report
 Dim CRapp As CRAXDDRT.Application
 Dim param As CRAXDDRT.ParameterFieldDefinition
 Dim crTable As CRAXDRT.DatabaseTable

 Set CRapp = New CRAXDDRT.Application
 
Set CRReport = CRapp.OpenReport(REPORT_PATH & "\Notes.rpt", 1)
    
CRReport.Database.Tables.Item(1).SetLogOnInfo &quot;<Server Name>&quot;, &quot;<DB_Name>&quot;, &quot;<DBUser Name>&quot;, &quot;<Passw>&quot;
/////////////////////////////

I am not using the RDC-designer, would that change anything?
(at this point I would prefer to keep on not using the designer)

I am also using a stored procedure as my only datasource

Thankful for any Help
 
Here's an abbreviated example (this assumes you could have more than 1 datasource per report, thus the for...next thru the tables collection):

Set crxReport = crxApp.OpenReport(mstrReportPath)
Set crxDatabase = crxReport.Database
Set crxDatabaseTables = crxDatabase.Tables

For Each crxDatabaseTable In crxDatabaseTables
strDSN = &quot;MyDSN&quot;
strDataBase = &quot;DBName&quot;
strUserName = &quot;sa&quot;
strPassWord = &quot;&quot;

Call crxDatabaseTable.SetLogOnInfo(strDSN, strDataBase, strUserName, strPassWord)

strLocation = &quot;DBName.dbo.Proc(sp_MyStoredProc;1)&quot;

Call crxDatabaseTable.SetTableLocation(strLocation,&quot;&quot; , &quot;&quot;)

next
 
almost there!

When I use your code I set the name of the SQLServer as strDSN, however the LogonServerName property of crxDatabaseTable refuses to change.

The other properties (DatabaseName, Username) work fine (only if you set strDSN=&quot;&quot; though)

If I use a report made in the designer (i.e change &quot;Set crxReport = crxApp.OpenReport(mstrReportPath)&quot; to &quot;Set crxReport = New CR_Report&quot; )

everything seems to work fine!
 
Have you updated the datasource(DSN) to point to the new database? You said you set it to the &quot;name of the SQL Server&quot;. In our case we assume there is a ODBC datasource that points to the correct DB, and the name of that DSN is the variable &quot;MyDSN&quot;.
 
addendum...
last line should be &quot;the name of that DSN in the variable strDSN&quot;
 
I'm using a OLE DB connection to SQLServer at the moment and would prefer not to use a ODBC connection. From what I have read, putting the name of the SQLServer in the &quot;Servername&quot; property in SetLogOnInfo should work.

Further findings:
If I use the automation server objects (CRPEAuto.Application & CRPEAuto.Databasetable) instead of the CRAXDrt objects this code works fine:
Code:
crpTable.SetLogOnInfo &quot;PROLIANT&quot;, &quot;KIM_Copy&quot;, &quot;sa&quot;, &quot;&quot;
crpTable.Location = &quot;KIM_Copy.dbo.Proc(usp_GetInformationRowReport;1)&quot;

I'm sort of new to CR but I have a hunch that using the automationserver objects isn't an optimal choice with regards to future development (feel free to inform me if this isn't correct).

So now I have 3 ways to solve my problem:
1. Remake the reports into .dsr files
2. Use the automationserver objects
3. Use a ODBC connection

I would still like to know though, if there is a way to make my first approch work.
 
I wouldn't recommend the automation server - I believe Seagate recommends the RDC, and other comments in this site have indicated this as well.

As far as why it's not working, I don't have any help. One thing to check - when you save your .rpt file, do you have &quot;save with data&quot; checked?

 
Purrepirre, please try this:
1. Open your Crystal Report
2. Look for &quot;Convert Database Drive&quot; usually under Database (Crystal Report 7.0)
3. Change Pdsodbc.dll(ODBC) to PdsSQL.dll(SQL Server)
4. Save your report

Then go to your app:
CRReport.Database.Tables.Item(1).SetLogOnInfo &quot;<Server Name>&quot;, &quot;<DB_Name>&quot;, &quot;<DBUser Name>&quot;, &quot;<Passw>&quot;

CRReport.Database.Tables(1).SetLogOnInfo strServerName, strDB, strUID, strPWD

Notice: ServerName now is the name of the server, NOT ODBC_DSN or ServerAlias
Hope this will work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top