cancel
Showing results for 
Search instead for 
Did you mean: 

SetLogin and SetConnection

Former Member
0 Kudos

I am confused about the differences between SetLogin and SetConnection.

How come I don't have to use SetLogin on the primary report but I do on the sub reports? Do I have to use SetLogin on the sub reports if I used SetConnection on the primary report? If I do need to use SetLogin on sub reports, can I do that setting useIntegratedSecurity to true?

Can a report have more than 1 datasource and if so, can one use integrated security while the other does not?

And how do you set connection without specifying the server or database name? If you just want to use the ones specified in the report?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Gary,

You can set log on without opening a report, it just connects you to a database server. When you open a report the report should assume that's the connection it uses and should just preview without prompting for log on info. If it's not then it will prompt.

Set Location is used if you want to update the database server info to another database server than the report was designed off of, example DEV to Production server.

As long as the main and subreports use the same connection then the subreport should use the main report connection. If you change Servers then you have to set location for bot main and sub report.

You can use multiple data sources but not recommended, you'll see a warning about limited functionality if you connect to more than one data sources, Data source being a DSN or DB Server.

If you must use more than one then use a subreport, and yes each main and subreport can use trusted authentication but you can't if the same server is used with multiple databases.

Hope that's clear?

Thank you

Don

Former Member
0 Kudos

Interesting and thank you so much! I have been having a heck of a time getting my head around all this. It seems like there are 10 different ways to do things and I never know if one way is preferred over the other.

So if I am not changing the database server, I do not use SetConnection. I only need to use SetLogin for the report. Then do I still need to SetLogin for each sub report then?

Also if I do need to use SetConnection on the main report, do I also need to use SetConnection on the sub reports or is it assumed since it was done to the parent report?

Thanks again!

Former Member
0 Kudos

If I do not need to use SetConnection and I use SetLogin, how do I use SetLogin so that it uses integrated security?

Thanks!

0 Kudos

So if I am not changing the database server, I do not use SetConnection. I only need to use SetLogin for the report. Then do I still need to SetLogin for each sub report then?

Correct.... only have to set logon for each subreport if they are not using the same connection as the main report.

Also if I do need to use SetConnection on the main report, do I also need to use SetConnection on the sub reports or is it assumed since it was done to the parent report?

Correct.... only have to set location for main and each subreport if they are also going to the new server.

When you create the report check the option on to use Trusted Authentication. You could try setting it also for each report when you first log in.

The DB server obviously needs to support NT Authentication, if not, then it won't work. And to make it work the user also must be added to the Server User list.

Don

Former Member
0 Kudos

how do I use SetLogin so that it uses integrated security?

Thanks again!

Former Member
0 Kudos

I know I keep going on and I am sorry about that. This will be my last reply. I have 4 possible scenarios and it is the 2nd scenario that I donu2019t know what to do:

Donu2019t change the server or database:

SetLogin(userName, password)

Donu2019t change the server or database and use integrated security:

???

Change the server or database:

SetConnection(server, database, userName, password)

Change the server or database and use integrated security:

SetConnection(server, database, true)

0 Kudos

Hi Gary,

Split Server and database apart in your thinking.

You can set Server info to be able to run the report as long as the Server has not changed when the report was designed you can simply refresh. The first time the report is run it will prompt you to log in. This is true also when using Trusted Authentication except no prompt, you simple get logged in using PC's user name and password. DB Server must be configured to do so of course.

If you want to set your report to the same server but a different database then use the Set Location option.

If you want to set the report to a new server but same database name then simply log on to the new server and then set location to verify the report.

When using Trusted Authentication you simply bypass the log on step. Just refresh a report and you'll be logged on, you won't be logged on until a DB connection is selected otherwise.

In all cases this updates the fully qualified Server and database name. And depending on the DB server depends how this works.

Exmaple:

MS SQL Server is Database.Owner.Table

Oracle is Server.Table

So when going from one server to another or even from DB to DB or Server to Server you sometimes have to use the set location on each table used in the report and you must Verify the database.

CR keeps the original or updated DB info and location in the RPT file. If you change the DB server or Database or bose from the original or updated info in any way then you MUST also Verify the database. Verifying updates the RPT file to use the new info when you save the report. If you don't save the report no changes are done.

This also is true if you change your database structure, each and every report MUST be verified and saved so CR can save the changes you did.

Hope this is clear?

Thanks

Don

Former Member
0 Kudos

Thank you!

You said: If you want to set your report to the same server but a different database then use the Set Location option.

Do you mean SetConnection or SetLocation?

Nowhere in my code do I logon to a server or refresh a report I donu2019t think. I am only manipulating the data source connection properties. Perhaps I am going about this all wrong?

I do not create the reports or know anything about the reports. In my application, the user specifies all, some, or none of the following properties:


<ServerName>
<DatabaseName>
<UserName>
<Password>

Then I loop all the data source connections in the parent report and all the data source connections in all the sub reports like this.

if (serverName != "" || dbaseName != "")
{
  if (userName == "") //Use integrated security
  {
    connectInfo.SetConnection(serverName, dbaseName, true);
  }
  else
  {
    connectInfo.SetConnection(serverName, dbaseName, userName, password);
  }
}
else //Not changing server name or databases so we just use SetLogin
{
  if (userName == "") //Use integrated security
  {
    //Don't know what to do here
  }
  else
  {
    connectInfo.SetLogon(userName, password);
  }
}

It is the last condition, when they are not changing server name or databases and they want to use integrated security that I am confused. Is this not the correct way to do this?

Don, if you are a consultant, I would be glad to pay you for an hour or so to help me make sure I am doing this correct. My application supports several different report types and all I have left is the data source connection options for Crystal Reports. After that I will be completely done with this application.

Edited by: Don Williams on May 20, 2011 8:42 AM

Former Member
0 Kudos

Sorry about the indentation in the code. I had it indented to make it easier to read but when I posted it, the formatting was removed.

0 Kudos

Hi Gary,

It would have been a lot quicker if you had mentioned this info was for coding.... I moved it to the .NET SDK forum.

Wrap your code snippets in "{"code"}" ( remove the double quotes ) then it formats it properly. I fixed your post.

Search in this forum for "ReplaceConnection_Click" and you'll find how to use RAS to st location to multiple sources. Thing to watch for are the type of DB, going from Oracle to MS SQL Server works most of the time but from MS to Oracle can cause problems. Fully qualified table names and field types don't match so it can cause problems for you when CR tries to map the fields. Same type server is not problem.

You can do another function so you don't have to change the connection each time, If your users always use the same DB then use the Summary Info ( not the formula ) to save an update flag of some sort. So if the report has been set to the new Users server then don't update/replace connection info, save the report with the updated info and then all that is required is to set the password. CR will never keep the password, security issues of course.

Sorry, I work for SAP Support and I don't consult on the side. You can call/contact our sales department to get you hooked up with one of our Consultants though....

Thanks again

Don

Former Member
0 Kudos

If I had mentioned this info was for coding? Where else would one use SetLogin and SetConnection?

I have no idea what this line means?

Summary Info ( not the formula ) to save an update flag of some sort

I am writing an application that uses the Crystal Report Viewer in C#. I am manipulating the data source connection properties to allow for different servers, databases, users, and iuntegrated security using the CrystalDecisions .NET assemblies. There are no formulas.

I am not touching any of the reports so I can't open them and do something and save it.

What is RAS?

0 Kudos

Hi Gary,

You posted your SDK question in the Report Design forum. I therefore assumed it was the report designer you wanted to know about because those same labels are in the Designer. And not knowing what language you were using it could be a translation problem or something like BabbleFish was used...

RAS is Report Application Server

Summary Info API is the same as in the Report Designer, File Summary info, it's the file system that saves the report info.

See these samples for more info:

Enterprise Samples (including managed and unmanaged ras)

http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsSDKSampleApplications

Non-Enterprise Samples

http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsSDKSampleApplications

Exporting Samples (RAS)

http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples#NETRASSDKSamples-Exporting%2FPrinting

Thanks again

Don

Former Member
0 Kudos

Sorry about posting to the wrong group. It was confusing when I first came to the SAP website because the last time I did antything with Crystal Reports was back when it was with Business Objects. The first time I posted, I posted to SAP Business One group and was told to post to the Crystal Reports group and when I looked, the only Crystal Reports group I could find was Crystal Reports designer.

So since I am not using RAS, do you know if I even need to use SetLogin if I am using integrated Security?

Thanks!

0 Kudos

Yes, look at the Non-Enterprise Samples.

Former Member
0 Kudos

Yes what? Yes I do need to use SetLogin even if I am using integrated security or ...?

Where are the Non-Enterprise Samples?

If you don't know, should I just start over and post my question in another group?

Thanks!

0 Kudos

Yes you have to tell the report which server you are using, no user or PW required as long as you set the Trusted authentication.

http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples

Use any of the log on samples and simply add the Trusted = True.

Don

Former Member
0 Kudos

Thanks Don,

The samples help alot.

If you are NOT changing the server or database, then you don't use SetConnection, you use SetLogin but SetLogin does not have a Trusted authentication property.

So are you saying that even if you are NOT changing the server or database and you want to use Trusted authentication then you HAVE to use SetConnection so that you can set the SetConnection.trustedConnection peoperty?

Answers (0)