Results 1 to 4 of 4

Thread: [RESOLVED] Record count =-1 what’s problem

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Resolved [RESOLVED] Record count =-1 what’s problem

    Hi all
    Using coding I m saving a folder image into a table using field I (text)
    It is saving successfully but when I m checking again it showing record count-1
    What is the reason behind it
    ……………
    help!!!!!!!!!!


    code are


    VB Code:
    1. FileName1 = App.Path & "\QuesImages\Chemistry"
    2. If text1.Text <> "" Then
    3.     Set f = Fs.GetFolder(FileName1)
    4.     Set fc = f.Files
    5.     For Each f1 In fc
    6.     S1 = S1 & f1.Name
    7.     S = "SELECT i FROM cheimage where i='" & Trim(S1) & "'"
    8.     Set R1 = Get_Special_Record_Set(S)
    9.     If R1.RecordCount = 0 Then
    10. 'showing record count=-1 here what is the reason HELP ME
    11.         MsgBox "Image " + S1 + " Not Found In Chemistry Folder ThereFore Restore Not Possible", vbInformation
    12.         S1 = ""
    13.         Exit Sub
    14.     End If
    15.     S1 = ""
    16.     Next
    17.     'Restoring The Folder
    18.     objFS.CopyFolder FileName1, text1.Text & "\QuesImages\Chemistry", True
    19. End If

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Record count =-1 what’s problem

    The RecordCount property of a recordset is not implemented for all providers, cursortypes and cursorlocations. If it is not implemented, it will always return -1.

    eg if you open a recordset by using the execute method of the connection, the RecordCount property will always return -1.
    The RecordCount property is not the most accurate property, because even when it is implemented, it only give reliable results if the complete recordset has been loaded.

    To check if the recordset returned results, use the EOF property.
    If EOF is true directly after opening the recordset, the recordset is empty.
    When the recordset is empty both EOF and BOF will be true.

    Your code will look like this:
    VB Code:
    1. FileName1 = App.Path & "\QuesImages\Chemistry"
    2. If text1.Text <> "" Then
    3.     Set f = Fs.GetFolder(FileName1)
    4.     Set fc = f.Files
    5.     For Each f1 In fc
    6.     S1 = S1 & f1.Name
    7.     S = "SELECT i FROM cheimage where i='" & Trim(S1) & "'"
    8.     Set R1 = Get_Special_Record_Set(S)
    9.     If R1.EOF and R1.BOF Then
    10.         MsgBox "Image " + S1 + " Not Found In Chemistry Folder ThereFore Restore Not Possible", vbInformation
    11.         S1 = ""
    12.         Exit Sub
    13.     End If
    14.     S1 = ""
    15.     Next
    16.     'Restoring The Folder
    17.     objFS.CopyFolder FileName1, text1.Text & "\QuesImages\Chemistry", True
    18. End If
    Frans

  3. #3

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Record count =-1 what’s problem

    If R1.EOF And R1.BOF Then
    it showing eof false and bof also false but there is 1000 record in the table

  4. #4

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Record count =-1 what’s problem

    ya franc i get the point thanks a lot i m going to rate u
    thanks a lot again

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