Print Page | Close Window

eliminate ODBC login credentials

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=342
Printed Date: 28 Apr 2024 at 1:42pm


Topic: eliminate ODBC login credentials
Posted By: aleplgr
Subject: eliminate ODBC login credentials
Date Posted: 18 Mar 2007 at 4:48am
Hi, I'm connecting by ODBC to a secure database, when I design the report it asks for my credentials and then I can add the tables to my report and works fine.
Now I'm running that report from a VB form asking the end user for a dates range, it works fine but before running the report the end user is prompted for credentials for every table that is used in the report.
 
I'm trying to add the Sub PrintPreview from Chapter 17 for Logging on With the Viewer Control.
So I've got the frmPreviewForm (the one that's used at the begining of  Chapter 21 for the CrystalReportViewer)
 
 and added the Sub to it for one of my tables:
 

Public Class frmPreviewForm

Inherits System.Windows.Forms.Form

Public Sub PrintPreview(ByVal UserId As String, ByVal Password As String)

Dim myReport As New CrystalReport1

Dim myLogOnInfo As CrystalDecisions.Shared.TableLogOnInfo

CrystalReportViewer1.LogOnInfo = New CrystalDecisions.Shared.TableLogOnInfos

myLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo

myLogOnInfo.TableName = "TRACTAMENTS"

With myLogOnInfo.ConnectionInfo

.UserID = UserId

.Password = Password

End With

CrystalReportViewer1.LogOnInfo.Add(myLogOnInfo)

myLogOnInfo.TableName = "TRACTAMENTS"

CrystalReportViewer1.ReportSource = myReport

End Sub

End Class

But it keeps asking for this table credentials, it seems that this PrintPreview Sub shouldn't be there...
 
 
  



Replies:
Posted By: hilfy
Date Posted: 18 Mar 2007 at 3:53pm
It looks like what you have should work fine.....Do you have subreports in this report?  If so, you also have to iterate through the subreports and set the logins there.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: aleplgr
Date Posted: 19 Mar 2007 at 4:06am

No, I don't have subreports.. it seems like this code is never executed because I put a  MsgBox("Hellooo") and it never appears..

I put the PrintPreview Sub  right before the end of the frmPreviewForm Class, should it be there?  I have just 2 forms: the one that runs the report with the 2 dates and the button to preview it and the frmPreviewForm where is the CrystalReportViewer1 Cry


Posted By: hilfy
Date Posted: 19 Mar 2007 at 11:22am
I got to thinking about it and I think I've found your problem.  You're creating object, but not loading the existing information into them to update the existing properties.
 
We're working from the ReportDocument object model, and not just from the CrystalReportViewer object model, so I don't have any sample code.  However, if you go to the http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm - BusinessObjects Developer Library , on the left side of the screen, click on "Crystal Reports .NET SDK", then " .NET Developer Guide and API Reference", then "Tutorials and Sample Code", then "CrystalReportViewer Object Model Tutorials", then "Logging onto a Secure SQL Server Database", you should be able to get to sample code that will get you closer than what you're doing.
Also, Brian may have some good examples for you.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: aleplgr
Date Posted: 20 Mar 2007 at 1:19am
ok, thanks Dell



Print Page | Close Window