|
Here's a quick piece of code from Martin Kusl on how to retrieve table names on the specified DNS:
WString name;
WString desc;
WBool r=true;
while( transaction->GetDataSourceInfo(&name,&desc,r) )
{
//name & desc
r=false;
}
// ListTables on DNS:
transaction->SetDataSource( DNS_NAME );
if( !transaction->Connect() ) return false;
WODBCDriver *drv=WODBCDriver::Load();
if( !drv ) return false;
if( !query->SetTransactionObject(transaction) ) return false;
HSTMT stmt=(HSTMT)query->GetHandle();
if( !stmt ) return false;
Another tip from Herbert Menke... This one about using shared data segments with Power++:
Although Power++ does not support shared data segments, it is possible to use shared data by separating shared and non-shared data segments.
extern "C" WDLLIMPORT WLong InterlockedIncrement( WLong * lpVariableAddress
);
extern "C" WDLLIMPORT WLong InterlockedDecrement( WLong * lpVariableAddress
);
extern "C" WDLLIMPORT WLong InterlockedExchange( WLong * lpVariableAddress,
WLong newValue );
Herbert Menke writes in with a tip about changing the look of the progress bar using the new common controls:
With new versions of the comctl32.dll (versions 4.70 and 4.71), the progressbar has 2 new styles and a function to change the colour of the bar.
If you want a smooth bar instead of the default segmented bar
(v4.70):
progb_1->SetStyle( progb_1->GetStyle() | WStyle(1), true);
To display the progress status vertically, from bottom to top
(v4.70):
progb_1->SetStyle( progb_1->GetStyle() | WStyle(4), true);
Finally, if you want to change to colour of the bar (v4.71):
progb_1->SendMessage(WMessage( 0x409, 0, color.GetRGB()));
You can download the newest version of comctl32 at: http://www.microsoft.com/msdn/downloads/files/40Comupd.exe.
Nat Vinod writes in with a tip on how to gain access to a database using one connection established by PowerBuilder by passing the dbhandle by using the PB function dbhandle():
Sharing a database transaction handle between PowerBuilder (or another development tool) and Power++: Note: In the example below the handle passed can be the GetConnectionHandle() from another Power++ transaction object or DBHandle() from PowerBuilder.
WTransaction sqlca;
WQuery query;
// Create or Init function
long WDLLEXPORT InitTrans( unsigned long handle )
{
bool ok;
ok = sqlca.Create( "ODBC" ); // Creates the ODBC transaction
object
// Below statement borrows the transaction object.
// However transaction is not a ref counted object and the set
// method does not set the connected property of sqlca to true.
ok = sqlca.SetConnectionHandle( handle );
ok = qry->Create( &sqlca ); // Connects the query to transaction
// this fails to call the query's
// connect method.
WODBCQuery * qry;
qry = (WODBCQuery *) query.GetQueryObject();
ok = qry->Connect();// Connects the query to transaction
// this should have been done by
// the Create call above but it did
// not because sqlca's connected
// property is false.
// Now it is possible to user qry or query because query
// redirects calls to qry. The query object now uses the
// borrowed transaction and can get its benefits.
ok = qry->SetSQL( "SELECT current user FROM DUMMY" );
ok = qry->Open();
ok = qry->MoveNext();
WString s = qry->GetValue( 1 ).GetCHAR();
ok = qry->Close(); // Calls Disconnect of query.
WMessageBox::Info( NULL, "", s );
return 1;
}
The key is to call the connect method of WODBCQuery. I have only tested this with ODBC transactions.