CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2000
    Posts
    5

    recordset.open <filename> problem

    I have an ADODB.recordset that I am generating programitically... it is not connected to a database table, file, or SQL command. I tried to do a recordset.sort on it and that caused an error.

    Is the sort method supported for a recordset that is not pointing to a table, file or SQL command?

    Also, while trying to do a work-around, I did a recordset.save to a file and then re-opened it. The recordset data looks great prior to saving the file, but once I re-open the rccordset from the file, some of the data is corrupted - specifically, the first character in some of the strings. Anybody have any ideas why this data was corrupted. I saved it in the ADTG format.

    Thanks.


    PSH

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: recordset.open <filename> problem

    here is a sample for sorting a recordset:

    Dim r as new ADODB.Recordset
    r.Fields.Append "test", adChar, 10
    r.Fields.Append "test2", adChar, 10
    r.CursorLocation = adUseClient
    r.Open
    r.Sort = "test"
    r.AddNew
    r.Fields(0) = "test"
    r.Fields(1) = "test2"
    r.Update
    r.AddNew
    r.Fields(0) = "atest"
    r.Fields(1) = "atest2"
    r.Update
    ' assign it to a data grid
    set g.DataSource = r




    This didn't work, when the data type for the fields was adBSTR, only with adCHAR.
    Also, you need to use Cursorlocation = adUseClient.



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

Featured