Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing Database for CrystalReportView webform object
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Divers
Thread ID:
00671726
Message ID:
00671736
Vues:
18
You need to add CrystalDecisions.Shared to your project's References. Then on the page, add the Imports statement:

Imports CrystalDecisions.Shared

When you do that the TableLogOnInfo class will be available.


>I have downloaded and read the "how-to's " from crystal report for vs.net, but a glaring function they don't talk about is how to create the login information for the report when accessing sql server data that requires a login.
>That is where I am boming. I have a webform with the control loaded, and the report is visible in the IDE. But when I do the DataBind() command, I bomb with a login error.
>There is a property in the databinding called LogOnInfo, but I have no idea what goes here. I cut my code from VFP program but it didn't like it. I think it is looking for an object or an array. I found the following example on msdn:
>
>
>The procedure for accessing secure databases through Crystal Reports for Visual Studio .NET differs between Web Forms
>and Windows Forms. In a Windows Form, a dialog box automatically prompts users to enter their user name and password.
>In a Web Form, however, you need to design a form that retrieves this information from the user. In both situations,
>you can use code to specify the user name and password, thereby giving the same level of security to all users of
>your application.
>
>
>Setting Database Logon Parameters
>
>The following example demonstrates how to pass logon parameters to the tables in a report. For this example,
>a connection to a secure SQL Server database is being used.
>
>Start a new project.
>Add a Button and four Textbox controls to the form.
>Name the TextBox controls serverNameTxt, dbNameTxt, userNameTxt, and passwordTxt.
>Double-click the Button control to specify code for the Click event. Depending on the language you are using,
>insert the appropriate.
>
>[Visual Basic]
>' Declare require variables.
>Dim logOnInfo As New TableLogOnInfo()
>Dim i As Integer
>
>' Loop through every table in the report.
>For i = 0 To report.Database.Tables.Count - 1
>   ' Set the connection information for current table.
>   logOnInfo.ConnectionInfo.ServerName = serverNameTxt.Text
>   logOnInfo.ConnectionInfo.DatabaseName = dbNameTxt.Text
>   logOnInfo.ConnectionInfo.UserID = userNameTxt.Text
>   logOnInfo.ConnectionInfo.Password = passwordTxt.Text
>   report.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
>Next i
>
>
>
>But the first Dim statement fails because it doesn't know what TableLogOnInfo() is.
>
>On my webform, the control is called CrystalReportView1.
>
>Anybody done this yet? Any help greatly appreciated.
>
>Here is the msdn link
>
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlmn/html/crtskaccessingsecuredatabases.asp
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform