-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: srkrishnakumar
Message 1 in Discussion

  To export crystal report data into pdf file,please use the following steps.

Step1. Create a New Asp.NET VB Based web application.
Step2. Into the WebForm1.aspx,drag and drop the following control from the Tool 
box.
1)Button control
2)Crystal report viewer
Step3.Add a DataSet component from Project/AddComponent menu.
Step4.In the Dataset u can see the server explorer,through this you can connect 
to the remote database server ,then select the table which u want to create in 
the crystal report and then drag into the dataset.
Step5.Add a new crystal report from Project/AddComponent menu.Now It displays 
one dialog box with heading "Standard Report Export".
Under the available datasource,you select "Project Data".From ProjectData,you 
select ADO.NET DataSet.From ADO.NET DataSets,u can select 
yourprojectname.Dataset1.
>From this u can select the table.Then Select the "Insert Table".So your 
>selected table is now available under the "Tables in report" column.Then press 
>the "Next " Button.Now Columns in the tables are listed,Now Select the columns 
>which you want to display in the crytal report,Then Press the Finish 
>button.Then add the following coding,

 Paragraph Heading N
Imports System.Data.SqlClient
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine

Public Class WebForm1
   
   Inherits System.Web.UI.Page
   Dim rpt As New CrystalReport1

   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles MyBase.Load
       'Put user code to initialize the page here

       Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
       Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
       Dim myDS As New Dataset1
       Dim myConnection As New SqlConnection
       Dim myCommand As New SqlCommand
       Dim myDA As New SqlDataAdapter

       'crpt4.SetDataSource(objDS.Tables(0))
       rpt = New CrystalReport1
       For Each myTable In rpt.Database.Tables
           myLogin = myTable.LogOnInfo
           myLogin.ConnectionInfo.Password = "database password"
           myLogin.ConnectionInfo.UserID = "database username"
           myTable.ApplyLogOnInfo(myLogin)
       Next

       
       Try
           myConnection = New SqlConnection("SERVER=servername;USER 
ID=dbusername;PWD=dbpassword;DATABASE=databasename;")
           myCommand.Connection = myConnection
           myCommand.CommandText = "select * from tablename"
           myCommand.CommandType = CommandType.Text
           myDA.SelectCommand = myCommand
           myDA.Fill(myDS, "tablename")
           rpt.SetDataSource(myDS)
           CrystalReportViewer1.ReportSource = rpt

       Catch ex As Exception

       End Try


   End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles Button1.Click
       Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions
       rpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
       rpt.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
       crDiskFileDestinationOptions.DiskFileName = "C:\rptfolder\MyRpt.doc"
       rpt.ExportOptions.DestinationOptions = crDiskFileDestinationOptions
       rpt.Export()

   End Sub
End Class


 Summary

 Here i used the ADO.NET Dataset,Instead of using SQlServer OLEDB 
connection.Try and give me feedback.

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to