C++ example

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
robkrater
Posts: 2
Joined: Thu 21 Jul 2011 14:05

C++ example

Post by robkrater » Thu 21 Jul 2011 15:31

Looking for a sample program in c++. tired to convert delphi samples but keep getting errors. I'm looking to create the object from the code

Stefan Padlo
Posts: 5
Joined: Wed 23 Mar 2011 23:02

Post by Stefan Padlo » Thu 21 Jul 2011 17:47

You have to be more precise...

But I'll give U some of my example code.

Let's say, that somewhere in Your form there's established TUniConnection object. Otherwise, you have to put some #pragma link ".obj" - it depends on the type of provider, create new object and Connect().

for example

Code: Select all

TUniConnection *con;
Dynamic - query:

Code: Select all

void __fastcall myForm::myFunc(void)
{
    TUniQuery *q = new TUniQuery(NULL);
    q->Connection = con; // important thing ;)
    q->SQL->Text = "SELECT * FROM example_table;";
    q->Open();
    // do your stuff, for example:
    ShowMessage(q->FieldByName("your_field")->AsString);
    delete q;   // always remember to free this object if U have finished
}
Hope it will help You a lil'.


Cheers,
Stefan

robkrater
Posts: 2
Joined: Thu 21 Jul 2011 14:05

Post by robkrater » Thu 21 Jul 2011 18:16

Thanks Stefan. I was able to figure it out.

Post Reply