Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2004, 06:14 AM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default add dataset values to Crystal Report fields

I have written this coad at page load:
And I have added two parameter fields BillID and Name to Crystal Report rpt1.

Dim cnn As MySqlConnection
        cnn = New MySqlConnection("SERVER=cltserver;username=root;pa ssword=;DATABASE=bizSPHERE")
        If cnn.State <> ConnectionState.Open Then cnn.Open()
        Dim sql As String
        sql = "select BillId, VenderID from tblbillMaster"
        Dim dA As New MySqlDataAdapter(sql, cnn)
        Dim DS As New DataSet
        dA.Fill(DS, "tblBillMaster")

        Dim CR As rpt1
        CR = New rpt1

        Dim myDBConInfo As New ConnectionInfo

        With myDBConInfo
            .ServerName = "cltserver"
            .DatabaseName = "Bizsphere"
            .UserID = "root"
            .Password = ""
        End With

        Dim myTableLogOnInfo As New TableLogOnInfo
        myTableLogOnInfo.ConnectionInfo = myDBConInfo

        Dim datarow As DataRow
        Dim i As Int16

        For Each datarow In DS.Tables(0).Rows

            Field.ParameterFieldName = "BillID"
            DisVal.Value = datarow(0)
            Field.CurrentValues.Add(DisVal)

            Field = New ParameterField
            DisVal = New ParameterDiscreteValue

            Field.ParameterFieldName = "name"
            DisVal.Value = datarow(1)
            Field.CurrentValues.Add(DisVal)
            Fields.Add(Field)
        Next

        CrystalReportViewer1.ParameterFieldInfo = Fields

        CrystalReportViewer1.ReportSource = CRYRpt1

        cnn.Close()

This coad is working correctly but the problem is that Only last record is adding to crystal report.No error is Coming.
So what should i do get all records.

regards

jeevan
 
Old November 9th, 2004, 08:10 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What is DisVal?

I don't see any "x = New y" statements in your loop. Usually when you do looping of this nature, you need to create a new object at the beginning, otherwise all the iterations of the loop are going to use the same instance of an object. When you add that object to a collection, it might not get added any more than once, depending on the object type. This appears to be what's happening with your situation.
 
Old November 9th, 2004, 12:39 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Why not just use a DataSet a s the datasource for your report and avoid the looping all toghether?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh database fields in crystal report designed tanusree_ghosh Crystal Reports 1 September 12th, 2011 12:08 PM
Adding fields to the crystal report Pravin.k Crystal Reports 2 January 3rd, 2008 09:35 AM
Generating a Crystal Report using a dataset. Condor76 Crystal Reports 2 February 19th, 2007 06:45 PM
Crystal Report Dataset Louisa VB.NET 2002/2003 Basics 0 August 8th, 2006 10:50 AM
add fields to a report dartcoach Access 2 March 9th, 2005 02:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.