Results 1 to 10 of 10

Thread: RecordCount(resolved)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Resolved RecordCount(resolved)

    hi,

    i always having problems in using RecordCount. It always give me -1 eventhough there are some records.

    below is part of my coding. i want to display the records in a MSFlexGrid. Before the display i check for the recordcount , if the record is > 15 , then the rows will +1. But i always getting the recordcount is -1 even there are many records. Can someone help me to solve this

    Private Sub fillDetails()

    MSFlexGrid1.Clear
    Dim row_counter As Integer
    row_counter = 1

    With MSFlexGrid1
    .FormatString = " No." & "|" & " Date" & "|" & " .............
    End With

    rs_f.Open "select * from FollowUp where EnqNo = " & Label1 & "", con, adOpenDynamic, adLockPessimistic


    If rs_f.RecordCount <> 0 Then
    G_RowCheck = rs_f.RecordCount
    If rs_f.RecordCount > 15 Then
    Me.MSFlexGrid1.Rows = rs_f.RecordCount + 1
    Else
    Me.MSFlexGrid1.Rows = 15
    End If
    Last edited by vivian2u; Apr 17th, 2005 at 11:18 AM.

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: RecordCount

    Quote Originally Posted by vivian2u
    hi,

    i always having problems in using RecordCount. It always give me -1 eventhough there are some records.

    below is part of my coding. i want to display the records in a MSFlexGrid. Before the display i check for the recordcount , if the record is > 15 , then the rows will +1. But i always getting the recordcount is -1 even there are many records. Can someone help me to solve this

    Private Sub fillDetails()

    MSFlexGrid1.Clear
    Dim row_counter As Integer
    row_counter = 1

    With MSFlexGrid1
    .FormatString = " No." & "|" & " Date" & "|" & " .............
    End With

    rs_f.Open "select * from FollowUp where EnqNo = " & Label1 & "", con, adOpenDynamic, adLockPessimistic


    If rs_f.RecordCount <> 0 Then
    G_RowCheck = rs_f.RecordCount
    If rs_f.RecordCount > 15 Then
    Me.MSFlexGrid1.Rows = rs_f.RecordCount + 1
    Else
    Me.MSFlexGrid1.Rows = 15
    End If

    Replace adOpenDynamic either with adOpenStatic or adOpenKeySet

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: RecordCount

    you may need to move to the end of the recordset to get a correct record count, then movefirst to go back to the start.

    rgds
    pete

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: RecordCount

    Quote Originally Posted by westconn1
    you may need to move to the end of the recordset to get a correct record count, then movefirst to go back to the start.

    rgds
    pete

    not necessary...

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: RecordCount

    not necessary...
    it has resolved similar problems for me in the past

    pete

  6. #6
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: RecordCount

    Quote Originally Posted by westconn1
    it has resolved similar problems for me in the past

    pete

    yah... i have also seen this working in some conditions..
    I think it is provider specific...

    I opened a recordset with Access table... and it didn't require me to movelast and movefirst before getting the recordcount..

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: RecordCount

    yeah i know i was using DAO at the time, i don't know if the same would apply to ADO, or even what vivian2u is using.

    hence i said "may need"

    pete

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: RecordCount

    Hi guys,

    Problem solved when i replace adOpenDynamic either with adOpenStatic or adOpenKeySet. Great !! Cheers !

    Vivian2u

  9. #9
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Re: RecordCount(resolved)

    Hi

    I olso confus with opendynamic and open static
    any one help to make clear pls, thanks


    kamus

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

    Re: RecordCount(resolved)

    Wouldnt this work?
    VB Code:
    1. rs_f.CursorLocation=adUseClient
    2. rs_f.Open "select * from FollowUp where EnqNo = " & Label1 & "", con, adOpenDynamic, adLockPessimistic

    I believe this would also return the correct recordcount even if its adOpenDynamic....

    I olso confus with opendynamic and open static
    any one help to make clear pls, thanks
    adOpenDynamic: Dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the recordset are allowed, except for bookmarks if the provider doesn't support them.
    adOpenKeyset: Keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your recordset. Data changes by other users are still visible.
    Last edited by dee-u; Apr 22nd, 2005 at 03:30 AM.
    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