Click here to Skip to main content
15,919,613 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Crystal Report Direct Print Pin
Girish_Sharma22-Jan-10 2:27
Girish_Sharma22-Jan-10 2:27 
GeneralRe: Crystal Report Direct Print Pin
thatraja22-Jan-10 2:39
professionalthatraja22-Jan-10 2:39 
GeneralRe: Crystal Report Direct Print Pin
Girish_Sharma23-Jan-10 1:06
Girish_Sharma23-Jan-10 1:06 
GeneralRe: Crystal Report Direct Print Pin
thatraja23-Jan-10 6:43
professionalthatraja23-Jan-10 6:43 
GeneralRe: Crystal Report Direct Print Pin
Girish_Sharma24-Jan-10 17:13
Girish_Sharma24-Jan-10 17:13 
GeneralRe: Crystal Report Direct Print Pin
thatraja24-Jan-10 21:25
professionalthatraja24-Jan-10 21:25 
GeneralRe: Crystal Report Direct Print Pin
Girish_Sharma24-Jan-10 22:08
Girish_Sharma24-Jan-10 22:08 
GeneralRe: Crystal Report Direct Print Pin
thatraja25-Jan-10 8:46
professionalthatraja25-Jan-10 8:46 
Hi, i have checked code, the issue is you are closing & disposing the Report Document object in Button1_Click event which was created there. For that you should create the Report Document object in class & then close & dispose in Page_Unload event.

use the code
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
                PrintMode="ActiveX" EnableDatabaseLogonPrompt="false" />
        <asp:Button ID="Button1" runat="server" Text="Button" />
VB
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Web

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Dim rptprint As New CrystalDecisions.CrystalReports.Engine.ReportDocument()

    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        rptprint.Close()
        rptprint.Dispose()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ocn As New System.Data.SqlClient.SqlConnection
        Dim oda As New System.Data.SqlClient.SqlDataAdapter("select * from Employees", ocn)
        Dim ods As New System.Data.DataSet()
        ocn.ConnectionString = "Data Source=RAJA;User ID=sa;Password=123;Initial Catalog=Northwind"
        oda.Fill(ods)

        rptprint.Load("C:\CrystalReport1.rpt")
        rptprint.SetDataSource(ods)

        ' For DB Login
        Dim crtableLogoninfos As New TableLogOnInfos()
        Dim crtableLogoninfo As New TableLogOnInfo()
        Dim crConnectionInfo As New ConnectionInfo()
        Dim CrTables As Tables
        crConnectionInfo.ServerName = "RAJA"
        crConnectionInfo.DatabaseName = "Northwind"
        crConnectionInfo.UserID = "sa"
        crConnectionInfo.Password = "123"

        CrTables = rptprint.Database.Tables
        For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next
        '/ For DB Login

        CrystalReportViewer1.ReportSource = rptprint
        CrystalReportViewer1.DataBind()

        ocn.Close()
        ocn.Dispose()
        ods.Dispose()
        oda.Dispose()
    End Sub
End Class
Here i want to inform you another thing, you can see the property EnableDatabaseLogonPrompt="false" in the designer. This is used for skip the Logon prompt in run time. And then i put the code for assigning the Database logon in codebehind('For DB Login '/For DB Login block) for run time.

Hope you can solve the issues using this code. let me know your feedback.

Regards,
thatraja
GeneralRe: Crystal Report Direct Print Pin
Girish_Sharma26-Jan-10 18:50
Girish_Sharma26-Jan-10 18:50 
GeneralRe: Crystal Report Direct Print Pin
thatraja1-Feb-10 21:40
professionalthatraja1-Feb-10 21:40 
GeneralRe: Crystal Report Direct Print Pin
shrikant.kudlur6-Apr-11 19:27
shrikant.kudlur6-Apr-11 19:27 
AnswerRe: Crystal Report Direct Print Pin
thatraja6-Apr-11 22:49
professionalthatraja6-Apr-11 22:49 
GeneralRe: Crystal Report Direct Print Pin
shrikant.kudlur10-Apr-11 20:18
shrikant.kudlur10-Apr-11 20:18 
AnswerRe: Crystal Report Direct Print Pin
thatraja11-Apr-11 5:17
professionalthatraja11-Apr-11 5:17 
GeneralRe: Crystal Report Direct Print Pin
shrikant.kudlur18-Apr-11 18:57
shrikant.kudlur18-Apr-11 18:57 
GeneralRe: Crystal Report Direct Print Pin
thatraja18-Apr-11 21:39
professionalthatraja18-Apr-11 21:39 
Questionauto complete feature Pin
chakran22-Jan-10 0:36
chakran22-Jan-10 0:36 
Questionlogin Pin
arkiboys22-Jan-10 0:30
arkiboys22-Jan-10 0:30 
AnswerRe: login Pin
Prosanta Kundu online22-Jan-10 0:41
Prosanta Kundu online22-Jan-10 0:41 
Questionhow to access textboxid dynamically Pin
vbmadhavi21-Jan-10 23:14
vbmadhavi21-Jan-10 23:14 
AnswerRe: how to access textboxid dynamically Pin
Prosanta Kundu online22-Jan-10 0:37
Prosanta Kundu online22-Jan-10 0:37 
Questionweb service error Pin
iamdking21-Jan-10 22:02
iamdking21-Jan-10 22:02 
AnswerRe: web service error Pin
SeMartens21-Jan-10 22:21
SeMartens21-Jan-10 22:21 
GeneralRe: web service error Pin
iamdking21-Jan-10 22:30
iamdking21-Jan-10 22:30 
QuestionHide and Show Buttons on the Clients Side Pin
Vimalsoft(Pty) Ltd21-Jan-10 21:45
professionalVimalsoft(Pty) Ltd21-Jan-10 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.