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

    Save records from DBGrid to Txt File

    Hi
    I have an application that is connected with SQLServer 2000 and BCB6.
    I have the records in DBGrid to saw them in my application.. My question is how i can save this records to txt file?? Any code ideas??
    My fields are: Name and Size

    So i want to save them in txt file.. Is possible that???
    i did something like this
    ADOTable1->SaveToFile("c:\\86.txt"); but is totally wrong because i want to save only the above 2 fields and all i get in this file is strange letters
    Please help

  2. #2
    Join Date
    Oct 2006
    Posts
    16

    Re: Save records from DBGrid to Txt File

    Try "manually" looping on the records and writing the relevant values to the file the way you want. There probably isn't a one-line solution to this...

  3. #3
    Join Date
    Jul 2006
    Posts
    285

    Re: Save records from DBGrid to Txt File

    what you mean? Any code ideas???

  4. #4
    Join Date
    Oct 2006
    Posts
    16

    Re: Save records from DBGrid to Txt File

    Following is what I meant expressed in semi-pseudo-code:

    for (int i = 0; i < ADOTable1->RecordCount; i++)
    {
    Write to file the values you want, e.g.:
    ADOTable1->FieldByName("Abc")->AsString + ", " + ADOTable1->FieldByName("Xyz")->AsString + ...
    }

  5. #5
    Join Date
    Jul 2006
    Posts
    285

    Re: Save records from DBGrid to Txt File

    Ok seem good but how i am gonna write it in file. I mean you dont use file.

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