need help in crystal report source

Last post 05-05-2008 6:29 AM by sasi.k. 5 replies.

Sort Posts:

  • Re: need help in crystal report source

    05-04-2008, 10:05 AM
    Answer
    • Loading...
    • joseabie
    • Joined on 04-07-2008, 4:56 AM
    • Abu Dhabi
    • Posts 158

    Imports System.Web.UI

    Imports System.Data.SqlClient

    Imports CrystalDecisions.Shared

    Imports CrystalDecisions.CrystalReports.Engine

     

    dim rpt as new ReportDocument

    Private Sub configureCrystalReports() Dim myconnectioninfo As ConnectionInfo = New ConnectionInfo()

    myconnectioninfo.DatabaseName = "test\SqlExpress"

    myconnectioninfo.UserID = "testsa"

    myconnectioninfo.Password = "password"

    SetDBLogOnForReport(myconnectioninfo)

    End Sub

    Private Sub SetDBLogOnForReport(ByVal myConnectionInfo As ConnectionInfo)

    Dim myTableLogonInfos As TableLogOnInfos = CrystalReportViewer1.LogOnInfo

    For Each myTabeLogoninfo As TableLogOnInfo In myTableLogonInfos

    myTabeLogoninfo.ConnectionInfo = myconnectioninfo

    Next

    End Sub

     

    '------------------------------- Above is for log on info, use the configureCrystalReports() in the click 'event

    Private Sub printPayRegister()

    Dim thisConnectionString As String = ConfigurationManager.ConnectionStrings("MYConnectionString").ConnectionString

    Dim myConn As SqlConnection = New SqlConnection(thisConnectionString)
    Dim MyCommand As New SqlCommand()

    MyCommand.Connection = myConn

    MyCommand.CommandText = "SP_PayregisterDetails '" & cmb_Month.SelectedItem.Value + "/" + txt_year.Text & "','" & emp_no & "','" & Department & "', '" & Grade & "'"

    MyCommand.CommandType = Data.CommandType.Text

    Dim myDa As New SqlDataAdapter

    myDa.SelectCommand = MyCommand

    Dim myDS As New DS() myDa.Fill(myDS, "SP_PayregisterDetails") 'Stored Procedure

    rpt.Load(Server.MapPath("PayRegisterA3.rpt"))

    rpt.SetDataSource(myDS)

    rpt.PrintOptions.PaperOrientation = PaperOrientation.Landscape

    Me.CrystalReportViewer1.ReportSource = rpt

    End Sub

    '-------------------------------------------------------------------------------------------------------------------- 

    'below is the code when u click a button

    printPayRegister()

    rpt.SetParameterValue(
    "Heading", "Pay Register for the Month of  january " ) 'Heading is the parameter name in the report

    configureCrystalReports() 'log on info

    rpt.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath(
    "~/Export/PayRegister.pdf")) exporting this report to pdf

    Dim popupscript As String = "<script language='javascript'>" + "window.open('Export/PayRegister.pdf');</script>"

    Page.ClientScript.RegisterStartupScript(Me.GetType(), "PopUpWindow", popupscript, False)

     

    'last two line is a small javascript for poping up the report when the user clicked

     

    hope u got something, by the way i forgot tell u I'm using ASP.Net  with VB....

  • Re: need help in crystal report source

    05-05-2008, 4:03 AM
    • Loading...
    • azwaralam
    • Joined on 01-28-2008, 11:01 AM
    • Posts 24

    Thanks for ur kind reply, i know this code but i wanna use crystalreportsource control in which you can use tag based information i want crystalreportsource control to be bind in code behin like below is the html code..

     

    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" ReportSourceID="CrystalReportSource1"

    Height="1056px" Width="921px" EnableDatabaseLogonPrompt="true" />

     

    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">

    <Report FileName="Report3.rpt">

    <Parameters>

    <CR:ControlParameter ControlID="CalendarPopup1" ConvertEmptyStringToNull="False" DefaultValue=""

    Name="@df" PropertyName="SelectedDate" ReportName="" />

    <CR:ControlParameter ControlID="CalendarPopup2" ConvertEmptyStringToNull="False" DefaultValue=""

    Name="@dt" PropertyName="SelectedDate" ReportName="" />

    </Parameters>

     

     

    </Report>

    </CR:CrystalReportSource>

     

    see i m passing parameters under crystalreportsource control but i dont know how to pass database server name, userid , password and database name and how can use this code in code behind.

  • Re: need help in crystal report source

    05-05-2008, 4:19 AM
    • Loading...
    • sasi.k
    • Joined on 03-26-2007, 8:27 AM
    • Posts 294

    Hi,

    Have a look on this thread , hope it will help you.

    http://forums.asp.net/p/1085551/1617150.aspx#1617150

    Regards,
    Sasi

    Please remember to click "Mark as Answer" on this post if it helped you.
  • Re: need help in crystal report source

    05-05-2008, 4:41 AM
    • Loading...
    • azwaralam
    • Joined on 01-28-2008, 11:01 AM
    • Posts 24

    Thanks for ur reply but how would i pass database login information in code behin by using crystalreportsource control ?

  • Re: need help in crystal report source

    05-05-2008, 6:29 AM
    • Loading...
    • sasi.k
    • Joined on 03-26-2007, 8:27 AM
    • Posts 294

    Hi,

    Try Like this

    CrystalReportSource1.ReportDocument.SetDatabaseLogon("sa", "password", "server", "database name"); CrystalReportSource1.ReportDocument.SetParameterValue("@id", 2);

    Regards,
    Sasi

    Please remember to click "Mark as Answer" on this post if it helped you.
Page 1 of 1 (6 items)