Results 1 to 5 of 5

Thread: Why we need to use more than one recordset in a app?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Why we need to use more than one recordset in a app?

    Hi,

    Could somebody explain me the use and advantage of using more recordsets in an application.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Why we need to use more than one recordset in a app?

    Typically I will use one Public recordset throughout an application.

    However, there are times when I need a second recordset for a specific issue. During those times, I will create an event level recordset, do what I need to do, then destroy it.

    Often you may need certain elements of one recordset as variables in another query which would generate another recordset. Once you are done with both, then the temp recordset gets destroyed and you continue on with your primary recordset.

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Why we need to use more than one recordset in a app?

    One Recordset may hold records from one table and another one holds records from a different table and you may need to perform some processing involving those records from the tables involved.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Why we need to use more than one recordset in a app?

    that depends your logic, comfortability and style...this is not mandatory to have one recordset in your app. Having so many recordsets also will cause problems if not closed properly...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Why we need to use more than one recordset in a app?

    At best you may just instantiate one when you need it then properly dispose of it afterwards like the ff...

    VB Code:
    1. Private Sub SetContainerGrid(Optional ByVal ControlNum As String = vbNullString)
    2.     Dim adoRecordset    As ADODB.Recordset
    3.     Dim strSQL          As String
    4.     Dim li              As ListItem
    5.    
    6.     strSQL = "SELECT ContainerNum, ContainerSize, ID FROM BrokerageContainers WHERE ControlNum = '" & ControlNum & "'"
    7.    
    8.     Set adoRecordset = New ADODB.Recordset
    9.     lvwContainers.ListItems.Clear
    10.     With adoRecordset
    11.         .Open strSQL, connImport, adOpenKeyset, adLockReadOnly
    12.         Do While Not .EOF
    13.             Set li = lvwContainers.ListItems.Add(Text:=.Fields("ContainerNum") & vbNullString)
    14.             li.Tag = .Fields("ID")
    15.             li.ListSubItems.Add Text:=.Fields("ContainerSize") & vbNullString
    16.             .MoveNext
    17.         Loop
    18.         .Close
    19.     End With
    20.     Set adoRecordset = Nothing
    21. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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