Martin,
Son de xHarbour, pero logicamente acceden a sus equivalentes de Advantage:
HB_FUNC( ADSCREATESQLSTATEMENT )
{
UNSIGNED32 u32RetVal;
ADSAREAP pArea;
ADSHANDLE adsStatementHandle;
char szAlias[ HARBOUR_MAX_RDD_ALIAS_LENGTH + 1 ];
BOOL fResult = FALSE;
ADSHANDLE hConnect = HB_ADS_PARCONNECTION( 3 );
if( hConnect )
{
u32RetVal = AdsCreateSQLStatement( hConnect, &adsStatementHandle );
if( u32RetVal == AE_SUCCESS )
{
if( hb_parni( 2 ) == ADS_CDX )
{
AdsStmtSetTableType( adsStatementHandle, ADS_CDX );
}
if( !hb_rddInsertAreaNode( "ADS" ) )
{
AdsCloseSQLStatement( adsStatementHandle );
}
else
{
pArea = hb_rddGetADSWorkAreaPointer();
if( pArea )
{
hb_strncpy( szAlias, ISCHAR( 1 ) ? hb_parc( 1 ) : "ADSSQL",
HARBOUR_MAX_RDD_ALIAS_LENGTH );
pArea->atomAlias = hb_rddAllocWorkAreaAlias( szAlias,
pArea->uiArea );
if( !pArea->atomAlias )
{
hb_rddReleaseCurrentArea();
}
else
{
pArea->hTable = 0;
pArea->hOrdCurrent = 0;
pArea->hStatement = adsStatementHandle;
fResult = TRUE;
}
}
}
}
}
hb_retl( fResult );
}
HB_FUNC( ADSEXECUTESQLDIRECT )
{
UNSIGNED32 ulRetVal;
ADSHANDLE hCursor = 0;
ADSAREAP pArea;
/* -----------------10/9/2005 2:51PM-----------------
bh removed test for adsConnectHandle as it is not actually used;
the func was just trying to confirm a real connection existed
but we're trying to remove dependence on statics;
if we saved the nConnection to a WA, that would take care of it.
As is, it requires pArea->hStatement which we only allow created if
there's Connection so we should be OK.
* --------------------------------------------------*/
if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) !=
0
&& pArea->hStatement && ISCHAR( 1 ) )
{
char * pucStmt = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) );
ulRetVal = AdsExecuteSQLDirect( pArea->hStatement, (UNSIGNED8 *)
pucStmt, &hCursor );
hb_adsOemAnsiFree( pucStmt );
if( ulRetVal == AE_SUCCESS )
{
if( hCursor )
{
DBOPENINFO pInfo;
memset( &pInfo, 0, sizeof( DBOPENINFO ) );
pInfo.abName = ( BYTE * ) "";
pInfo.fReadonly = TRUE;
pArea->hTable = hCursor;
SELF_OPEN( ( AREAP ) pArea, &pInfo );
}
else
{
adsCloseCursor( pArea );
}
hb_retl( TRUE );
}
else
{
AdsShowError( (UNSIGNED8 *) "ExecuteSQL error:" );
hb_retl( FALSE );
}
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSPREPARESQL )
{
UNSIGNED32 ulRetVal;
ADSAREAP pArea;
/* -----------------10/9/2005 2:51PM-----------------
bh removed test for adsConnectHandle as it is not actually used;
the func was just trying to confirm a real connection existed
but we're trying to remove dependence on statics;
if we saved the nConnection to a WA, that would take care of it.
As is, it requires pArea->hStatement which we only allow created if
there's Connection so we should be OK.
* --------------------------------------------------*/
if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) !=
0
&& pArea->hStatement && ISCHAR( 1 ) )
{
char * pucStmt = hb_adsOemToAnsi( hb_parc( 1 ), hb_parclen( 1 ) );
ulRetVal = AdsPrepareSQL( pArea->hStatement, (UNSIGNED8 *) pucStmt );
hb_adsOemAnsiFree( pucStmt );
if( ulRetVal == AE_SUCCESS )
{
hb_retl( TRUE );
}
else
{
AdsShowError( (UNSIGNED8 *) "PrepareSQL error:" );
hb_retl( FALSE );
}
}
else
{
hb_retl( FALSE );
}
}
HB_FUNC( ADSEXECUTESQL )
{
UNSIGNED32 ulRetVal;
ADSHANDLE hCursor = 0;
ADSAREAP pArea;
/* -----------------10/9/2005 2:51PM-----------------
bh removed test for adsConnectHandle as it is not actually used;
the func was just trying to confirm a real connection existed
but we're trying to remove dependence on statics;
if we saved the nConnection to a WA, that would take care of it.
As is, it requires pArea->hStatement which we only allow created if
there's Connection so we should be OK.
* --------------------------------------------------*/
if( /*adsConnectHandle &&*/ ( pArea = hb_rddGetADSWorkAreaPointer() ) !=
0
&& pArea->hStatement )
{
ulRetVal = AdsExecuteSQL( pArea->hStatement, &hCursor );
if( ulRetVal == AE_SUCCESS )
{
if( hCursor )
{
DBOPENINFO pInfo;
memset( &pInfo, 0, sizeof( DBOPENINFO ) );
pInfo.abName = ( BYTE * ) "";
pInfo.fReadonly = TRUE;
pArea->hTable = hCursor;
SELF_OPEN( ( AREAP ) pArea, &pInfo );
}
else
{
adsCloseCursor( pArea );
}
hb_retl( 1 );
}
else
{
AdsShowError( (UNSIGNED8 *) "ExecuteSQL error:" );
hb_retl( 0 );
}
}
else
{
hb_retl( 0 );
}
}
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Martin del Angel" <
martindelangel@msn.com> escribió en el mensaje
news:[email=
46523e4c@ozsrv2.ozlan.local...]
46523e4c@ozsrv2.ozlan.local...[/email]
> Hola a Todos !
>
> Mirando en el codigo de AdsDataSource.prg
>
>
> AdsCreateSqlStatement( "ADSSQL", 2 )
> AdsExecuteSqlDirect( cCommand )
>
> He estado buscando en todos los archivos de ayuda de Advantage y no veo
> esas funciones, no si son de Xharbour o de Advantage ?
>
>
>
> Gracias....
>
>
> Saludos.
>
>
>
>