Print Page | Close Window

Load Records From ADO Recordset

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=4560
Printed Date: 16 September 2024 at 7:44pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Load Records From ADO Recordset
Posted By: DueSoft
Subject: Load Records From ADO Recordset
Date Posted: 08 July 2006 at 12:50am
Hi...

Please help me...

How to adding records item from ado recordset?

Thank's B4.



Replies:
Posted By: sserge
Date Posted: 09 July 2006 at 8:49am
Hi,

This should be done via your code:
-- open a recordset;
-- iterate all records;
-- for every of them, create a corresponding ReportRecord object;
-- for every field of the record, add a corresponding ReportRecordItem object to the ReportRecord (for corresponding columns).
-- call ReportControl.Populate

--
WBR,
Serge


Posted By: DueSoft
Date Posted: 09 July 2006 at 11:41pm
Thank's B4,

I'm is new use this control, can you help me.
please tell me way to write it's code?

Thank's


Posted By: OscarM
Date Posted: 10 July 2006 at 3:02am
  Dim pCol As ReportColumn
  Dim pRecord As ReportRecord, pItem As ReportRecordItem
  Dim pField As ADODB.Field
  Dim i As Long
 
  For Each pField In Rs.Fields
    With Rp1
      Set pCol = .Columns.Add(i, pField.Name, 100, True)
      Select Case pField.Type
        Case adBigInt, adDecimal, adDouble, adInteger, adNumeric, adSingle, adSmallInt, adTinyInt
          'todo
        Case adBoolean
          'todo
        Case adDate, adDBDate, adDBTime, adDBTimeStamp
          'todo
      End Select
    End With
  Next
 
  Do Until Rs.EOF
    Set pRecord = Rp1.Records.Add
    For Each pField In Rs.Fields
      If pField.Type = adBoolean Then
        Set pItem = pRecord.AddItem("")
        pItem.HasCheckbox = True
        pItem.Checked = pField.Value = True
      Else
        Set pItem = pRecord.AddItem(pField.Value)
      End If
    Next
    Rs.MoveNext
  Loop
 
  Rp1.Populate
 
  Set pCol = Nothing
  Set pField = Nothing
  Set pRecord = Nothing
  Set pItem = Nothing


Posted By: DueSoft
Date Posted: 10 July 2006 at 10:32pm


It's Great!

But sorry, i'm done understand about this code,
'-------------------------------------------
      Select Case pField.Type
        Case adBigInt, adDecimal, adDouble, adInteger, adNumeric, adSingle, adSmallInt, adTinyInt
          'todo
        Case adBoolean
          'todo
        Case adDate, adDBDate, adDBTime, adDBTimeStamp
          'todo
      End Select
'------------------------------------------------------
When i try this code, i have a problem,
For example :
I have data like this :
----------------------------------
|No   |Name        |Phone      |
----------------------------------
|1    |Boy          |123456    |
|2    |David        |25633     |
----------------------------------

when i try, the result is like this :
----------------------------------
|No   |Name        |Phone      |
----------------------------------
|1    |1            |1        |
|1    |1            |1        |
----------------------------------

Why???? and what i do in code 'todo', please help me....
Can you send me fully code or VB Project for this code?


Thank's
Best Regards.


Posted By: Timothy5
Date Posted: 03 March 2007 at 8:47pm
I have a similar issue when I use columns that meet the Case conditions. What is the solution?


Posted By: Timothy5
Date Posted: 03 March 2007 at 9:04pm

Added i = i + 1 just after the case statement to correct the issue.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net