Results 1 to 4 of 4

Thread: CR setdatasource not chnaging data

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304

    CR setdatasource not chnaging data

    well I am almost at my wirs end.

    I have seen all sorts of posts over the net and I know this is a common problem but even following the advice, just can't seem to get it ti work.

    The problem exhibited is that the data opn the crystal report doesn't chanage when the data in the dataset does.

    Here is my code and I am using VB .Net with the supplied Crystal Reports Version 9.

    At this point any and all advice gladly welcomed.

    Public Sub loadme(ByVal RptName As String, ByVal DsNam As String, ByVal Selec As String)
    Dim logOnInfo As New TableLogOnInfo
    Dim Rpt1 As New ReportDocument
    Dim DbNam As String

    Dim RptPath As String
    RptPath = RptLocn.RptDir
    Rpt1.PrintOptions.PaperOrientation = PaperOrientation.Landscape
    Rpt1.Load(RptPath & "\" & RptName & ".rpt")
    ' Pass the populated data set to the report.
    logOnInfo = Rpt1.Database.Tables.Item(DsNam).LogOnInfo

    Dim connectionInfo As New ConnectionInfo
    connectionInfo = Rpt1.Database.Tables.Item(DsNam).LogOnInfo.ConnectionInfo

    ' Set the Connection parameters.
    connectionInfo.DatabaseName = "lams"
    connectionInfo.ServerName = "LOCALHOST"
    connectionInfo.Password = " "
    connectionInfo.UserID = " "
    Rpt1.Database.Tables.Item(DsNam).ApplyLogOnInfo(logOnInfo)
    Rpt1.ReportOptions.EnableSaveDataWithReport = False

    Dim p1 As New ParameterField
    p1.ParameterFieldName = "RegUser"
    Dim p2 As New ParameterFields
    Dim d1 As New ParameterDiscreteValue
    d1.Value = UserName.RegUsr
    p1.CurrentValues.Add(d1)
    p2.Add(p1)
    CrystalReportViewer1.ParameterFieldInfo = p2

    Dim SqlStr As String = "Select * from " & DsNam & " " & Selec
    DbNam = DbConn.CurrCon
    Dim Cn1 As New OleDbConnection(DbNam)
    Dim da1 As New OleDbDataAdapter
    da1.TableMappings.Add("Table", DsNam)
    da1.SelectCommand = New OleDbCommand(SqlStr, Cn1)
    Dim ds1 As New DataSet
    ' Connect to the data source, fetch the data, and disconnect
    ds1.Clear()
    da1.Fill(ds1, DsNam)
    Rpt1.SetDataSource(ds1)
    CrystalReportViewer1.ReportSource = Rpt1
    CrystalReportViewer1.DisplayGroupTree = False
    CrystalReportViewer1.Width = Me.Width

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Try unchecking the 'Discard Saved Data When Loading Reports' option if its checked. It is in the Designer Default Settings under the Reporting tab. Also try calling the Refresh method (or RefreshReport or whatever its called).

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    thanks
    tried both suggestions and neother of them had any effect

    Richard

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    This is crazy, I have actually given up on using setdatasource and gone to using the pull method and the recordselection formula where it works just fune. I spent hours chasing around the net and it seems to be a common problem - the only good thing was that I discovered you have to use a collection info object and logoninfo to make sure that Crystal Reports picks up the correct server and database name when distributed to run on other machines.

    I can't understand this about Crystal Reports I have been having so many problems and that stupid default setting which has to be changed to prevent uour data being saved with the report!!

    Anyone else got niggles or other problems with Crystal Reports?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width