Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.5 KiB

  1. Attribute VB_Name = "Recordset"
  2. Option Explicit
  3. Public Sub AppendField( _
  4. ByVal i_fld As ADODB.Field, _
  5. ByVal o_rs As ADODB.Recordset _
  6. )
  7. o_rs.Fields.Append i_fld.Name, i_fld.Type, i_fld.DefinedSize, i_fld.Attributes
  8. End Sub
  9. Public Sub CreateFields( _
  10. ByVal i_rsSource As ADODB.Recordset, _
  11. ByVal o_rsDest As ADODB.Recordset _
  12. )
  13. Dim fld As ADODB.Field
  14. For Each fld In i_rsSource.Fields
  15. o_rsDest.Fields.Append fld.Name, fld.Type, fld.DefinedSize, fld.Attributes
  16. Next
  17. End Sub
  18. Public Sub CopyFields( _
  19. ByVal i_rsSource As ADODB.Recordset, _
  20. ByVal o_rsDest As ADODB.Recordset _
  21. )
  22. Dim fld As ADODB.Field
  23. For Each fld In i_rsSource.Fields
  24. o_rsDest.Fields(fld.Name).Value = fld.Value
  25. Next
  26. End Sub
  27. Public Sub CopyRecordSet( _
  28. ByVal i_rsSource As ADODB.Recordset, _
  29. ByVal o_rsDest As ADODB.Recordset _
  30. )
  31. CloseRecordSet o_rsDest
  32. CreateFields i_rsSource, o_rsDest
  33. o_rsDest.Open
  34. If (i_rsSource.EOF) Then
  35. Exit Sub
  36. End If
  37. i_rsSource.MoveFirst
  38. Do While (Not i_rsSource.EOF)
  39. o_rsDest.AddNew
  40. CopyFields i_rsSource, o_rsDest
  41. i_rsSource.MoveNext
  42. Loop
  43. o_rsDest.MoveFirst
  44. End Sub
  45. Public Sub CloseRecordSet( _
  46. ByVal o_rs As ADODB.Recordset _
  47. )
  48. If (o_rs.State = adStateOpen) Then
  49. ' This record set has some old data. Lose it.
  50. o_rs.Close
  51. End If
  52. End Sub