|
-
Aug 8th, 2003, 11:20 AM
#1
Thread Starter
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|