Page 1 of 1

C++ example

Posted: Thu 21 Jul 2011 15:31
by robkrater
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

Posted: Thu 21 Jul 2011 17:47
by Stefan Padlo
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

Posted: Thu 21 Jul 2011 18:16
by robkrater
Thanks Stefan. I was able to figure it out.