CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 1999
    Posts
    26

    ADO Control Question

    I am creating a recordset within my VB6 program using the ADO control.

    I would like to append fields of variable length strings.

    Could someone provide sample code of this.

    Currently, this is a sample of my code:

    r.Fields.Append "Field1", adChar, 25
    r.Fields.Append "Field2", adChar, 14
    r.Fields.Append "Field3", adChar, 255
    r.Fields.Append "Field4", adChar, 25
    r.Fields.Append "Field5", adChar, 25
    r.Fields.Append "Field6", adChar, 25

    This code works, but the fields are of fixed lengths.

    If I change the code to the following, I get a runtime error when trying to
    sort the field.

    r.Fields.Append "Field1", adBSTR

    r.Sort "Field1"

    The error message is "The requested order could not be opened"

    I would like to be able to sort a variable length string.

    Is that possible?

    If so, how would I create the recordset so that this would work?

    Any help would be greatly appreciated.

    Thanks




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

    Re: ADO Control Question

    did you try that adVarChar property I mentioned yesterday?


  3. #3
    Join Date
    Jul 1999
    Posts
    26

    Re: ADO Control Question

    I tried it, but get the runtime error
    "The requested order could not be opened"

    when I try to do a sort.

    r.Sort = "Field"

    If I go back and replace the append with

    r.Fields.Append "Field1", adChar, 25

    I do not get the runtime error.

    Any ideas?




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