Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Linking a database to a MemoBox(C++)

  • 12-04-2003 03:38PM
    #1
    Closed Accounts Posts: 6


    Hi all,
    I have a memobox with a letter, including the field headings such as <Name1>, <Name2> etc
    I want to link these field names with a database called "Maildata.mdb".
    I have already created the database with the same field headings.
    I want to replace <Name1>, <Name2> etc in the memobox with the data contained in the database.

    File *in;

    in = fopen("MailData.mdb","r");

    if(Form1->Memo1->SelText == "<name1>"){
    Memo1->SelText =

    This is the point where I am stuck, how do I assign the database to the SelText i.e <Name1> in the MemoBox?

    I would appreciate any help with this
    Thanks
    Clarabell


Comments

  • Registered Users, Registered Users 2 Posts: 2,157 ✭✭✭dazberry


    Originally posted by clarabell
    Hi all,
    I want to link these field names with a database called "Maildata.mdb".
    I have already created the database with the same field headings.
    I want to replace <Name1>, <Name2> etc in the memobox with the data contained in the database.

    File *in;

    in = fopen("MailData.mdb","r");

    if(Form1->Memo1->SelText == "<name1>"){
    Memo1->SelText =


    You appear to be opening the database as a binary file, and from the extension it looks like an access database ??? If you have actually created the database in say Access, you will need to open the database using something like the BDE (shudder) or better layer.

    If you do, it will be available from a TDataSet decendant, so you can use something like
    Memo1->SelText = myDataSet.FieldByName('name1') -> asString.

    However, if you've created the database as a binary file (fixed length records), you'll need to load it into a record (struct in C) and access the specific member. My C is far to rusty to remember how to do that.

    D.


Advertisement