Login failed
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
BindReport()
End Sub
Sub BindReport()
Dim myConnection As New SqlClient.SqlConnection()
myConnection.ConnectionString = "data source=localhost;integrated security=sspi;database=mydatabase"
Dim MyCommand As New SqlClient.SqlCommand()
MyCommand.Connection = myConnection
MyCommand.CommandText = "Select * from mytable "
MyCommand.CommandType = CommandType.Text
Dim MyDA As New SqlClient.SqlDataAdapter()
MyDA.SelectCommand = MyCommand
Dim myDS As New Dataset1()
MyDA.Fill(myDS, "mytable")
Dim oRpt As New CrystalReport1()
oRpt.SetDataSource(myDS)
For Each myTable In oRpt.Database.Tables
myLogin = myTable.LogOnInfo
myTable.ApplyLogOnInfo(myLogin)
Next
CrystalReportViewer1.ReportSource = oRpt
'''''''''''''''''''''
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myReport As CrystalReport1 = New CrystalReport1()
Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions ()
myReport.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
myReport.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
DiskOpts.DiskFileName = "c:\Output.pdf"
myReport.ExportOptions.DestinationOptions = DiskOpts
Try
myReport.Export()
Catch e1 As Exception
Response.Write(e1.Message)
End Try
End Sub
'So my crystal report shown results accuratilly but when i click on button for export report then error show which is "Login failed"
|