Soporte de MySQL para FWPPC !!!

Soporte de MySQL para FWPPC !!!

Postby Antonio Linares » Thu Feb 19, 2009 9:12 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Soporte de MySQL para FWPPC !!!

Postby Salvador » Tue Apr 21, 2009 4:36 pm

Algun experto en SQL y c++ que se atreva aportarla a FWPPC?.

Code: Select all  Expand view
//***********************************************************
//              SQL Server CE Interface Function           //
//                                                         //
//                     Author : Chris C                    //
//                    PassportONE.com                                  //
//                http://www.PassportONE.com                           //
//               Email:  chris@PassportONE.com                       //
//                       © Aug 2002                        //
//                                                         //
//***********************************************************

#include "SqlSvrCe.h"


// -------------------------------------------------------
//
// SQL SERVER CE INTERFACE FUNCTION
//
// -------------------------------------------------------

HRESULT CreateSqlSvrCeProvider (void)
{
    //  PURPOSE:  
    //      - Initlialize the OLE DB Provider...
    //  PARAMETERS:
    //      - NIL
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    HRESULT     hr = NOERROR;
   
    // Create the SQL Server CE provider
    hr = CoCreateInstance(CLSID_SQLSERVERCE_2_0,
                          0,
                          CLSCTX_INPROC_SERVER,
                          IID_IDBInitialize,
                          (void**)&pIDBInitialize);

    return hr;
}

HRESULT CreateDBSession (void)
{
    //  PURPOSE:  
    //      - Create a new SQL Server CE Database session of the connected database...
    //  PARAMETERS:
    //      - NULL
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    HRESULT             hr = NOERROR;
   
    // Query the IDBCreateSession interface
    hr = pIDBInitialize->QueryInterface(IID_IDBCreateSession,
                                        (void **)&pIDBCreateSession);
    if(FAILED(hr))
        goto CleanExit;
    else
        pIDBInitialize->AddRef();

    // Create a new database session...
    hr = pIDBCreateSession->CreateSession(NULL,
                                          IID_IUnknown,
                                          &pIUnknownSession);
    if(FAILED(hr))
        goto CleanExit;

    // Query the IDBCreateCommand interface
    hr = pIUnknownSession->QueryInterface(IID_IDBCreateCommand,
                                          (void**)&pIDBCrtCmd);
    if(FAILED(hr))
        goto CleanExit;
    else
        pIUnknownSession->AddRef();

    // Create a command object pointer
    hr = pIDBCrtCmd->CreateCommand(NULL,
                                   IID_ICommandText,
                                   (IUnknown**)&pICmdText);
    if(FAILED(hr))
        goto CleanExit;

CleanExit:

    return hr;

}

HRESULT ConnectDB (LPTSTR lpszDBName)
{
    //  PURPOSE:  
    //      - Connect the given SQL Server CE Database
    //  PARAMETERS:
    //      - lpszDBName    :: SQL Server CE Database filename in fullpath
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    HRESULT             hr = NOERROR;
   
    DBPROPSET           dbpropset[1];   // Property Set used to initialize provider
    DBPROP              dbprop[1];      // property array used in property set to initialize provider
   
    // Create the SQL Server CE provider
    hr = CreateSqlSvrCeProvider();
    // Validation
    if(FAILED(hr))
        goto CleanExit;

    // Initialize...
    VariantInit(&dbprop[0].vValue);

    // Initialize a property with name of database
    dbprop[0].dwPropertyID   = DBPROP_INIT_DATASOURCE;
    dbprop[0].dwOptions      = DBPROPOPTIONS_REQUIRED;
    dbprop[0].vValue.vt      = VT_BSTR;
    dbprop[0].vValue.bstrVal = SysAllocString(lpszDBName);

    // Validation
    if(NULL == dbprop[0].vValue.bstrVal)
    {
        // Set return value
        hr = E_OUTOFMEMORY;
        goto CleanExit;
    }

    // Initialize the property set
    dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
    dbpropset[0].rgProperties    = dbprop;
    dbpropset[0].cProperties     = sizeof(dbprop)/sizeof(dbprop[0]);

    // Query the IDBProperties interface
    hr = pIDBInitialize->QueryInterface(IID_IDBProperties,
                                        (void **)&pIDBProperties);
    // Validation
    if(FAILED(hr))
        goto CleanExit;
    else
        pIDBInitialize->AddRef();

    // Create the given database...
    hr = pIDBProperties->SetProperties(sizeof(dbpropset)/sizeof(dbpropset[0]),
                                       dbpropset);
    // Validation
    if(FAILED(hr))
        goto CleanExit;

    // Free the used memory
    SysFreeString(dbprop[0].vValue.bstrVal);
   
    // Initialize the SQL Server CE provider.
    pIDBInitialize->Initialize();

    // Create new database session...
    hr = CreateDBSession();

CleanExit:
    // Release the used memory
    VariantClear(&dbprop[0].vValue);
   
    // Only execute the following command when either one of the
    // above command fail.
    if (FAILED(hr))
        // Disconnect the database/reset the OLE DB variable
        DisconnectDB(lpszDBName);

    return hr;
}

HRESULT DisconnectDB (LPTSTR lpszDBName)
{
    //  PURPOSE:  
    //      - Disconnect from the given SQL Server CE Database
    //  PARAMETERS:
    //      - lpszDBName    :: SQL Server CE Database filename in fullpath
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    if(NULL != pIDBCreateSession)
    {
        pIDBCreateSession->Release();
        pIDBCreateSession = NULL;
    }

    if(NULL != pIUnknownSession)
    {
        pIUnknownSession->Release();
        pIUnknownSession = NULL;
    }

    if(NULL != pIDBProperties)
    {
        pIDBProperties->Release();
        pIDBProperties = NULL;
    }

    if(NULL != pIDBCrtCmd)
    {
        pIDBCrtCmd->Release();
        pIDBCrtCmd = NULL;
    }

    if(NULL != pICmdText)
    {
        pICmdText->Release();
        pICmdText = NULL;
    }

    // Release interfaces
    if(NULL != pIDBInitialize)
    {
        pIDBInitialize->Release();
        pIDBInitialize = NULL;
    }

    return S_OK;
}

HRESULT CreateDB (LPTSTR lpszDBName)
{
    //  PURPOSE:  
    //      - Create a new SQL Server CE Database with the given name
    //  PARAMETERS:
    //      - lpszDBName    :: SQL Server CE Database filename in fullpath
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    HRESULT             hr = NOERROR;
   
    DBPROPSET           dbpropset[1];   // Property Set used to initialize provider
    DBPROP              dbprop[1];      // property array used in property set to initialize provider

    IDBDataSourceAdmin  *pIDBDataSourceAdmin = NULL;

    // Create the SQL Server CE provider
    hr = CreateSqlSvrCeProvider();
    // Validation
    if(FAILED(hr))
        goto CleanExit;
   
    // Initialize...
    VariantInit(&dbprop[0].vValue);

    // Initialize a property with name of database
    dbprop[0].dwPropertyID   = DBPROP_INIT_DATASOURCE;
    dbprop[0].dwOptions      = DBPROPOPTIONS_REQUIRED;
    dbprop[0].vValue.vt      = VT_BSTR;
    dbprop[0].vValue.bstrVal = SysAllocString(lpszDBName);

    // Validation
    if(NULL == dbprop[0].vValue.bstrVal)
    {
        // Set return value
        hr = E_OUTOFMEMORY;
        goto CleanExit;
    }

    // Initialize the property set
    dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
    dbpropset[0].rgProperties    = dbprop;
    dbpropset[0].cProperties     = sizeof(dbprop)/sizeof(dbprop[0]);

    // Query the IDBDataSourceAdmin interface
    hr = pIDBInitialize->QueryInterface(IID_IDBDataSourceAdmin,
                                        (void **)&pIDBDataSourceAdmin);
    // Validation
    if(FAILED(hr))
        goto CleanExit;
    else
        pIDBInitialize->AddRef();

    // Create the given database...
    hr = pIDBDataSourceAdmin->CreateDataSource(1,
                                               dbpropset,
                                               NULL,
                                               IID_IDBProperties,
                                               NULL);
    // Validation
    if(FAILED(hr))
        // Clean the memory...
        goto CleanExit;
   
    // Free the used memory
    SysFreeString(dbprop[0].vValue.bstrVal);

    // Create new database session...
    hr = CreateDBSession();

CleanExit:
    // Release the used memory
    VariantClear(&dbprop[0].vValue);
   
    // Release the OLE DB interface
    if(NULL != pIDBDataSourceAdmin)
    {
        pIDBDataSourceAdmin->Release();
        pIDBDataSourceAdmin = NULL;
    }

    // Only execute the following command when either one of the
    // above command fail.
    if (FAILED(hr))
        // Disconnect the database/reset the OLE DB variable
        DisconnectDB(lpszDBName);

    return hr;
}

HRESULT DeleteDB (LPTSTR lpszDBName)
{
    //  PURPOSE:  
    //      - Delete an existing SQL Server CE Database with the given name
    //  PARAMETERS:
    //      - lpszDBName    :: SQL Server CE Database filename in fullpath
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT
   
    if (DeleteFile(lpszDBName) > 0)
        return S_OK;
    else
        return E_FAIL;

}

HRESULT CompactDB (LPTSTR lpszDBName)
{
    //  PURPOSE:  
    //      - Compact an existing SQL Server CE Database with the given name
    //  PARAMETERS:
    //      - lpszDBName    :: SQL Server CE Database filename in fullpath
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    HRESULT         hr = NOERROR;
    TCHAR           szNewDBName[256];

    // Property Set used to initialize provider
    DBPROPSET       compactdbpropset[1];
    DBPROPSET       dbpropset[1];
    // Property array used in property set to initialize provider
    DBPROP          compactdbprop[1];
    DBPROP          dbprop[1];
    ISSCECompact    *pISSCECompact = NULL;
   
    // Create the SQL Server CE provider
    hr = CreateSqlSvrCeProvider();
    // Validation
    if(FAILED(hr))
        goto CleanExit;

    // Initialize...
    VariantInit(&dbprop[0].vValue);

    // Initialize a property with name of database
    dbprop[0].dwPropertyID   = DBPROP_INIT_DATASOURCE;
    dbprop[0].dwOptions      = DBPROPOPTIONS_REQUIRED;
    dbprop[0].vValue.vt      = VT_BSTR;
    dbprop[0].vValue.bstrVal = SysAllocString(lpszDBName);

    // Validation
    if(NULL == dbprop[0].vValue.bstrVal)
    {
        // Set return value
        hr = E_OUTOFMEMORY;
        goto CleanExit;
    }

    // Initialize the property set
    dbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
    dbpropset[0].rgProperties    = dbprop;
    dbpropset[0].cProperties     = sizeof(dbprop)/sizeof(dbprop[0]);

    // Query the IDBProperties interface
    hr = pIDBInitialize->QueryInterface(IID_IDBProperties,
                                        (void **)&pIDBProperties);
    // Validation
    if(FAILED(hr))
        goto CleanExit;
    else
        pIDBInitialize->AddRef();

    // Create the given database...
    hr = pIDBProperties->SetProperties(sizeof(dbpropset)/sizeof(dbpropset[0]),
                                       dbpropset);
    // Validation
    if(FAILED(hr))
        goto CleanExit;

    // Free the used memory
    SysFreeString(dbprop[0].vValue.bstrVal);
   
    // Initialize the SQL Server CE provider.
    pIDBInitialize->Initialize();

    // Get ISSCECompact interface
    hr = pIDBProperties->QueryInterface(IID_ISSCECompact,
                                        (void **)&pISSCECompact);
    // Validation
    if(FAILED(hr))
        goto CleanExit;
    else
        pIDBProperties->AddRef();

    // Initialize Property with name of new compacted database
    compactdbprop[0].dwPropertyID   = DBPROP_INIT_DATASOURCE;
    compactdbprop[0].dwOptions      = DBPROPOPTIONS_REQUIRED;
    compactdbprop[0].vValue.vt      = VT_BSTR;

    // Create new database name
    memset(szNewDBName, TEXT('\0'), 256);
    wsprintf(szNewDBName, TEXT("%sx"), lpszDBName);
    // new name for compacted database
    compactdbprop[0].vValue.bstrVal = SysAllocString(szNewDBName);

    // Initialize property set
    compactdbpropset[0].guidPropertySet = DBPROPSET_DBINIT;
    compactdbpropset[0].rgProperties    = compactdbprop;
    compactdbpropset[0].cProperties     = sizeof(compactdbprop)/sizeof(compactdbprop[0]);

    // Compact the database using the provider-specific interface
    hr = pISSCECompact->Compact(sizeof(compactdbpropset)/sizeof(compactdbpropset[0]),
                                compactdbpropset);

    // Release the interface
    pISSCECompact->Release();
    pISSCECompact = NULL;

    // Disconnect the database/reset the OLE DB variable
    DisconnectDB(lpszDBName);

    // Overwrite the original database
    if (!CopyFile(szNewDBName, lpszDBName, false))
    {
        // Set the return value
        hr = E_FAIL;
        goto CleanExit;
    }

    // Delete the temp database...
    DeleteDB(szNewDBName);


CleanExit:
    // Release the used memory
    VariantClear(&dbprop[0].vValue);

    // Only execute the following command when either one of the
    // above command fail.
    if (FAILED(hr))
        // Disconnect the database/reset the OLE DB variable
        DisconnectDB(lpszDBName);

    return hr;

}

HRESULT CreateTable (LPTABLECOLUMNINFO lptci)
{
    //  PURPOSE:  
    //      - Create new table with the specified table name.
    //  PARAMETERS:
    //      - lptci :: Target column information.
    //  OPERATION:
    //      - Compose SQL-92 command
    //      - Execute the SQL-92 command with ExecuteSQL interface
    //  RETURN VALUE:
    //      - HRESULT

    // CREATE TABLE ABC (MyField INT IDENTITY (s,i) NOT NULL CONSTRAINT PK_MyField PRIMARY KEY [UNIQUE])

    TCHAR   szBuffer[2048]   = {NULL};
    TCHAR   szSQL92[2048]    = {NULL};

    // Get the SQL92 command
    GetSQL92ColumnDef(lptci, (LPTSTR)&szSQL92, 2048);

    // Compose the SQL-92 command
    wsprintf(szBuffer,
             TEXT("CREATE TABLE %s (%s)"),
             lptci->szTableName, szSQL92);

    // Execute the SQL-92 command
    return ExecuteSQL(szBuffer);

}

HRESULT DropTable (LPTSTR lpszTableName)
{
    //  PURPOSE:  
    //      - Drop the existing table with the specified table name
    //  PARAMETERS:
    //      - lpszTableName :: Existing target table name.
    //  OPERATION:
    //      - Compose SQL-92 command
    //      - Execute the SQL-92 command with ExecuteSQL interface
    //  RETURN VALUE:
    //      - HRESULT

    TCHAR   szBuffer[2048]  = {NULL};

    // Compose the SQL-92 command
    wsprintf(szBuffer,
             TEXT("DROP TABLE %s"),
             lpszTableName);

    // Execute the SQL-92 command
    return ExecuteSQL(szBuffer);

}

HRESULT CreateColumn (LPTABLECOLUMNINFO lptci)
{
    //  PURPOSE:  
    //      - Create new column with the specified column information
    //  PARAMETERS:
    //      - lptci :: Target column information.
    //  OPERATION:
    //      - Compose SQL-92 command
    //      - Execute the SQL-92 command with ExecuteSQL interface
    //  RETURN VALUE:
    //      - HRESULT

    TCHAR   szBuffer[2048]   = {NULL};
    TCHAR   szSQL92[2048]    = {NULL};

    // Get the SQL92 command
    GetSQL92ColumnDef(lptci, (LPTSTR)&szSQL92, 2048);

    // Compose the SQL-92 command
    wsprintf(szBuffer,
             TEXT("ALTER TABLE %s ADD %s"),
             lptci->szTableName, szSQL92);

    // Execute the SQL-92 command
    return ExecuteSQL(szBuffer);

}

HRESULT DropColumn (LPTABLECOLUMNINFO lptci)
{
    //  PURPOSE:  
    //      - Drop the existing column with the specified column information
    //  PARAMETERS:
    //      - lptci :: Target column information..
    //  OPERATION:
    //      - Compose SQL-92 command
    //      - Execute the SQL-92 command with ExecuteSQL interface
    //  RETURN VALUE:
    //      - HRESULT

    TCHAR   szBuffer[2048]  = {NULL};

    // Compose the SQL-92 command
    wsprintf(szBuffer,
             TEXT("ALTER TABLE %s DROP COLUMN %s"),
             lptci->szTableName, lptci->szColumnName);

    // Execute the SQL-92 command
    return ExecuteSQL(szBuffer);

}

HRESULT CreateIndex (LPTABLEINDEXINFO lptii)
{
    //  PURPOSE:  
    //      - Create new index with the specified index information
    //  PARAMETERS:
    //      - lptii :: 32-Bits long pointer point to TABLEINDEXINFO structure
    //  OPERATION:
    //      - Compose SQL-92 command
    //      - Execute the SQL-92 command with ExecuteSQL interface
    //  RETURN VALUE:
    //      - HRESULT

    TCHAR   szBuffer[2048]  = {NULL};
    TCHAR   szUnique[8]     = {NULL};
   
    // Validate the Unique mode.
    if (lptii->bUnique)
        _tcscpy(szUnique, TEXT("UNIQUE"));
    else
        _tcscpy(szUnique, TEXT(""));

    // Compose the SQL-92 command
    // NOTE:
    //      DUE TO SQL CE 2.0 DOES NOT SUPPORT CLUSTERED INDEX,
    //      HENCE, NONCLUSTERED KEYWORD IS APPLIED IN THIS CASE.
    wsprintf(szBuffer,
             TEXT("CREATE %s NONCLUSTERED INDEX %s ON %s (%s)"),
             szUnique, lptii->szIndexName, lptii->szTableName, lptii->szIndexFields);

    // Execute the SQL-92 command
    return ExecuteSQL(szBuffer);

}

HRESULT DropIndex (LPTABLEINDEXINFO lptii)
{
    //  PURPOSE:  
    //      - Drop the existing index with the specified index information
    //  PARAMETERS:
    //      - lptii :: 32-Bits long pointer point to TABLEINDEXINFO structure
    //  OPERATION:
    //      - Compose SQL-92 command
    //      - Execute the SQL-92 command with ExecuteSQL interface
    //  RETURN VALUE:
    //      - HRESULT

    TCHAR   szBuffer[2048]  = {NULL};

    // Compose the SQL-92 command
    wsprintf(szBuffer,
             TEXT("DROP INDEX %s.%s"),
             lptii->szTableName, lptii->szIndexName);

    // Execute the SQL-92 command
    return ExecuteSQL(szBuffer);

}

HRESULT GetSQL92ColumnDef (LPTABLECOLUMNINFO lptci, LPTSTR lpszBuffer, int nMaxBuffer)
{
    //  PURPOSE:  
    //      - Build the SQL92 comand for ALTER/CRAETE column statement
    //  PARAMETERS:
    //      - lptci         :: Target column information.
    //      - lpszbuffer    :: Output buffer
    //      - nMaxBuffer    :: Output buffer size
    //  OPERATION:
    //      - Check through the pass in column information and build the respective
    //        SQL92 command
    //  RETURN VALUE:
    //      - HRESULT

    TCHAR   szColumnType[64] = {NULL};
    TCHAR   szIdentity[32]   = {NULL};
    TCHAR   szAcceptNull[16] = {NULL};
    TCHAR   szPrimaryKey[64] = {NULL};
    TCHAR   szUnique[8]      = {NULL};

    // Check user define column type
    {
        switch (lptci->nColumnType)
        {
            case 0:
                // int
                _tcscpy(szColumnType, TEXT("INT"));
                break;
            case 1:
                // smallint
                _tcscpy(szColumnType, TEXT("SMALLINT"));
                break;
            case 2:
                // tinyint
                _tcscpy(szColumnType, TEXT("TINYINT"));
                break;
            case 3:
                // bigint
                _tcscpy(szColumnType, TEXT("BIGINT"));
                break;
            case 4:
                // float
                _tcscpy(szColumnType, TEXT("FLOAT"));
                break;
            case 5:
                // nvarchar
                wsprintf(szColumnType,
                         TEXT("NVARCHAR (%d)"),
                         lptci->nColumnSize);
                break;
            case 6:
                // nchar
                wsprintf(szColumnType,
                         TEXT("NCHAR (%d)"),
                         lptci->nColumnSize);
                break;
            case 7:
                // bit
                _tcscpy(szColumnType, TEXT("BIT"));
                break;
            case 8:
                // datetime
                _tcscpy(szColumnType, TEXT("DATETIME"));
                break;
            case 9:
                // numeric
                _tcscpy(szColumnType, TEXT("NUMERIC"));
                break;
            default:
                // Default empty string
                _tcscpy(szColumnType, TEXT(""));
        }
    }

    // Check IDENTITY flag
    {
        if (lptci->bIdentity)
            wsprintf(szIdentity,
                     TEXT("IDENTITY (%d,%d)"),
                     HIWORD(lptci->dwIdentityProp), LOWORD(lptci->dwIdentityProp));
        else
            _tcscpy(szIdentity, TEXT(""));
    }

    // Check ACCPETNULL flag
    {
        if (lptci->bAcceptNull)
            _tcscpy(szAcceptNull, TEXT("NULL"));
        else
            _tcscpy(szAcceptNull, TEXT("NOT NULL"));
    }

    // Check PRIMARY KEY flag
    {
        if (lptci->bPrimaryKey)
            wsprintf(szPrimaryKey,
                     TEXT(", CONSTRAINT %s PRIMARY KEY (%s)"),
                     lptci->szPrimaryKeyName, lptci->szColumnName);
        else
            _tcscpy(szPrimaryKey, TEXT(""));
    }

    // Check UNIQUE flag
    {
        if (lptci->bUnique)
            _tcscpy(szUnique, TEXT("UNIQUE"));
        else
            _tcscpy(szUnique, TEXT(""));
    }

    // initialize the output buffer
    memset(lpszBuffer, TEXT('\0'), nMaxBuffer);
    // Copy result into the output buffer
    wsprintf(lpszBuffer,
             TEXT("%s %s %s %s %s %s"),
             lptci->szColumnName, szColumnType, szIdentity, szAcceptNull, szPrimaryKey, szUnique);

    return NOERROR;
}

HRESULT ExecuteSQL (LPTSTR lpszQuery)
{
    //  PURPOSE:  
    //      - Execute the given SQL statement.
    //  PARAMETERS:
    //      - lpszQuery :: SQL query command string.
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    HRESULT hr = NOERROR;

    // Set the SQL query statement
    hr = pICmdText->SetCommandText(DBGUID_SQL,
                                   lpszQuery);
    if(FAILED(hr))
        goto CleanExit;

    // Execute the SQL query statement without return any Rowset
    hr = pICmdText->Execute(NULL,
                            IID_NULL,
                            NULL,
                            NULL,
                            NULL);

CleanExit:

    return hr;
}

HRESULT GetRowset (LPTSTR lpszQuery)
{
    //  PURPOSE:  
    //      - Execute the given SQL statement and return a RowSet object.
    //  PARAMETERS:
    //      - lpszQuery :: SQL query command string.
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    // NOTE:
    //      THE FOLLOWING CODE SHOW HOW TO CREATE A ROWSET OBJECT
    //      WITH COMMAND OBJECT (SQL STATEMENT).

    HRESULT         hr = NOERROR;
   
    IRowset         *pIRowset       = NULL;
    ICommandText    *pICommandText  = NULL;


    // Create a command object pointer
    hr = pIDBCrtCmd->CreateCommand(NULL,
                                   IID_ICommandText,
                                   (IUnknown**)&pICommandText);
    // Validation
    if(FAILED(hr))
        goto CleanExit;

    // Set the SQL query statement
    hr = pICommandText->SetCommandText(DBGUID_SQL,
                                       lpszQuery);
   
    if(FAILED(hr))
        goto CleanExit;

    // Execute the SQL query statement
    hr = pICommandText->Execute(NULL,
                                IID_IRowset,
                                NULL,
                                NULL,
                                (IUnknown **)&pIRowset);

    if (!FAILED(hr))
    {
        if(NULL != pIRowset)
            // Proceed to walk through the retrieve Rowset object
            ProcessRowset(pIRowset);
    }
   
CleanExit:

    if (NULL != pIRowset)
    {
        pIRowset->Release();
        pIRowset = NULL;
    }

    if (NULL != pICommandText)
    {
        pICommandText->Release();
        pICommandText = NULL;
    }

    return hr;
}

HRESULT ProcessRowset (IRowset *pIRowset)
{
    //  PURPOSE:  
    //      - Retrieve and display data resulting from
    //        a query specified in GetRowset function
    //  PARAMETERS:
    //      - NIL
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT

    HRESULT         hr = NOERROR;
   
/*
    // FOR LISTVIEW USED ONLY
    LVCOLUMN    pcol;
    LVITEM      pitem;
    long        idx=0;
    long        lTotalRows  = 0;
    static long lTotalCols  = 0;
    long        t1=0;
    long        t2=0;
    long        elapse=0;
    int         iHour, iMinute, iSecond, iMiliSec;

    ULONG           lColumn     = 0;
    ULONG           lNumCols    = 0;
    ULONG           lCount      = 0;
    ULONG           lNumRowsRetrieved = 0;
    ULONG           ConsumerBufColOffset = 0;
   
    IAccessor       *pIAccessor    = NULL;
    IColumnsInfo    *pIColumnsInfo = NULL;
    DBCOLUMNINFO    *pDBColumnInfo = NULL;
    DBBINDING       *pBindings     = NULL;

    HACCESSOR       hAccessor      = NULL;
    HROW            hRows[10];
    HROW            *pRows         = &hRows[0];
    BYTE            *pBuffer       = NULL;

    WCHAR           *pStringsBuffer = NULL;

    TCHAR           szBuffer[1024];

    // NOTE:
    //      THE FOLLOWING CODE SHOW THE GENERATE METHOD TO DISPLAY
    //      THE READED ROWSET COLUMN DATA INTO LISTVIEW.
    //      HENCE, FOR BETTER EFFICIENTCY, THE FOLLOWING CODE
    //      MUST BE MODIFIED TO SUITE THE NEED WITH REFERENCE TO
    //      THE RESPECTIVE ROWSET.
   
    // Get the start time (CPU Tick)
    t1 = GetTickCount();
   
    // Obtain access to the IColumnInfo interface, from the Rowset object.
    hr = pIRowset->QueryInterface(IID_IColumnsInfo,
                                  (void **)&pIColumnsInfo);
    // Validation
    if(FAILED(hr))
    {
        // Update status
        UpdateList(TEXT("Failed to query IColumnsInfo interface!"));
        // Terminate the current routine
        goto CleanExit;
    }
    else
        pIRowset->AddRef();

    // Retrieve the column information.
    pIColumnsInfo->GetColumnInfo(&lNumCols,
                                 &pDBColumnInfo,
                                 &pStringsBuffer);

    // Free the column information interface.
    pIColumnsInfo->Release();

    // Create a DBBINDING array.
    pBindings = new DBBINDING[lNumCols];

    // Using the ColumnInfo structure, fill out the pBindings array.
    for(lCount=0; lCount<lNumCols; lCount++)
    {
        pBindings[lCount].iOrdinal      = lCount+1;
        pBindings[lCount].obValue       = ConsumerBufColOffset;
        pBindings[lCount].pTypeInfo     = NULL;
        pBindings[lCount].pObject       = NULL;
        pBindings[lCount].pBindExt      = NULL;
        pBindings[lCount].dwPart        = DBPART_VALUE;
        pBindings[lCount].dwMemOwner    = DBMEMOWNER_CLIENTOWNED;
        pBindings[lCount].eParamIO      = DBPARAMIO_NOTPARAM;
        // NOTE:
        //      DUE TO THE OUTPUT DATA TYPE OF EACH FIELDS WAS
        //      CONVERTED INTO "DBTYPE_WSTR" WITHIN THE SQL SERVER CE
        //      (HARDCODED) INSTEAD OF USING THE ORIGINAL DATA TYPE AS:
        //          pBindings[lCount].wType
        //      AS A RESULT, IT WILL NO LONGER FOLOOW THE VALUE STORE
        //      IN pDBColumnInfo[lCount].ulColumnSize
        //
        //      HENCE, THE MAXIMUM COLUMN SIZE WAS SET TO 48BYTES
        //      IT CAN BE ANY VALUE, AS LONG AS IT IS LARGE ENOUGH
        //      TO HOLD THE CONVERTED DATA FOR ALL THE READ COLUMNS.
        pBindings[lCount].cbMaxLen      = 48;
        pBindings[lCount].dwFlags       = 0;
        // NOTE:
        //      DUE TO DATA CONVERSION ERROR, SO WE HARDCODED THE
        //      DATA TYPE TO DBTYPE_WSTR INSTEAD OF USING THE DATA
        //      TYPE OBTAIN FROM THE DBCOLUMNINFO STRUCTURE AS:
        //          DBColumnInfo[lCount].wType
        //      THROUGH THE GetColumnInfo INTERFACE
        pBindings[lCount].wType         = DBTYPE_WSTR;
        pBindings[lCount].bPrecision    = pDBColumnInfo[lCount].bPrecision;
        pBindings[lCount].bScale        = pDBColumnInfo[lCount].bScale;
        // NOTE:
        //      DUE TO THE DATA TYPE WAS HARDCODED TO DBTYPE_WSTR. HENCE
        //      THE "ColumnSize" VALUE IN THE DBCOLUMNINFO STRUCTURE AS:
        //          pDBColumnInfo[lCount].ulColumnSize
        //      WILL NO LONGER APPLICABLE AND THE NEW HARDCODED SIZE OF
        //      48 BYTES WAS USED IN THIS CASE.
        //      THIS VALUS SHOULD BE CHANGE ARCCODING TO THE DEFINE DATA
        //      TYPE AND NOT NECESSARY MUST BE 48 BYTES.
 
        // Compute the next buffer offset.
        ConsumerBufColOffset += 48; //pDBColumnInfo[lCount].ulColumnSize;
    };

    // Get the IAccessor interface.
    hr = pIRowset->QueryInterface(IID_IAccessor,
                                  (void **)&pIAccessor);
    // Validation
    if(FAILED(hr))
    {
        // Update status
        UpdateList(TEXT("Failed to query IAccessor interface!"));
        // Terminate the current routine
        goto CleanExit;
    }
    else
        pIRowset->AddRef();

    // Create an accessor from the set of bindings (pBindings).
    pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA,
                               lNumCols,
                               pBindings,
                               0,
                               &hAccessor,
                               NULL);

    // ------------------------------------------------------------
    // NOTE:
    //      THE FOLLOWING CODE CAN BE REMOVE, IF THE COLUMN CAPTION
    //      DOES NOT REQUIRE.
    // ------------------------------------------------------------
    // [REMOVABLE CODE - START]

    if (lTotalCols > 0)
    {
        // Clear all the previous listview item
        SendMessage(hWndList1, LVM_DELETEALLITEMS, 0, 0);
        // Clear the previous column header
        for (idx=0; idx<lTotalCols; idx++)
        {
            SendMessage(hWndList1, LVM_DELETECOLUMN, (int)0, 0);
        };
    }

    // Setup column names.
    for(lCount=0; lCount<lNumCols; lCount++)
    {
        // Initialize listview column structure
        pcol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
        pcol.fmt = LVCFMT_LEFT;
        pcol.pszText = pDBColumnInfo[lCount].pwszName;
        //pcol.cx = 80;
        pcol.cx = SendMessage(hWndList1, LVM_GETSTRINGWIDTH, 0, (LPARAM)pDBColumnInfo[lCount].pwszName) + 16;
        // Append listview column
        SendMessage(hWndList1, LVM_INSERTCOLUMN, lCount, (LPARAM)&pcol);
    };
    //
    lTotalCols = lNumCols;
    // [REMOVABLE CODE - END]

    // Get a set of 10 rows.
    pIRowset->GetNextRows(NULL,
                         0,
                         10,
                         &lNumRowsRetrieved,
                         &pRows);

    // Allocate space for the row buffer.
    pBuffer = new BYTE[ConsumerBufColOffset];

    // Display the rows.
    while(lNumRowsRetrieved > 0)
    {
        //For each row, print the column data.
        for(lCount=0; lCount<lNumRowsRetrieved; lCount++)
        {
            // Initialize...
            memset(pBuffer, 0, ConsumerBufColOffset);
            // Get the row data values.
            pIRowset->GetData(hRows[lCount], hAccessor, pBuffer);
           
            // -- Item
            pitem.mask = LVIF_TEXT;
            pitem.iItem = SendMessage(hWndList1, LVM_GETITEMCOUNT, 0, 0);
            pitem.pszText = (LPTSTR)&pBuffer[pBindings[0].obValue];
            pitem.iSubItem = 0;
            // Insert item
            idx = SendMessage(hWndList1, LVM_INSERTITEM, 0, (LPARAM)&pitem);

            // Walk through each columns...
            for (lColumn=1; lColumn<lNumCols; lColumn++)
            {
                pitem.mask = LVIF_TEXT;
                pitem.iItem = idx;
                pitem.pszText = (LPTSTR)&pBuffer[pBindings[lColumn].obValue];
                pitem.iSubItem = lColumn;
                // Insert subitem
                SendMessage(hWndList1, LVM_SETITEM, 0, (LPARAM)&pitem);        
            }

            // Update the total column counter by 1
            lTotalRows++;
        };

        // Release the rows retrieved.
        pIRowset->ReleaseRows(lNumRowsRetrieved,
                              hRows,
                              NULL,
                              NULL,
                              NULL);

        // Get the next set of 10 rows.
        pIRowset->GetNextRows(NULL,
                              0,
                              10,
                              &lNumRowsRetrieved,
                              &pRows);
    };
   
    {
        // Get the complete time (CPU Tick)
        t2 = GetTickCount();
        // Calculate the total time
        elapse   = (t2 - t1)/1000;
        iHour    = elapse/3600;
        iMinute  = (elapse/60) - (iHour*60);
        iSecond  = elapse - (iHour*3600) - (iMinute*60);
        iMiliSec = (t2-t1) - (elapse*1000);

        // Initialize...
        memset(szBuffer, TEXT('\0'), 1024);
        // Compose...
        wsprintf(szBuffer, TEXT("\r\n(%ld row(s) affected)\r\nElapsed time %02d:%02d:%02d.%03d"), lTotalRows, iHour, iMinute, iSecond, iMiliSec);
        // Update Mesasge display
        UpdateList(szBuffer);
    }

    // Set return value
    hr = S_OK;

CleanExit:

    if (NULL != pIColumnsInfo)
    {
        pIColumnsInfo->Release();
        pIColumnsInfo = NULL;
    }

    if (NULL != pBindings)
    {
        delete [] pBindings;
        pBindings = NULL;
    }

    if (NULL != pIAccessor)
    {
        pIAccessor->Release();
        pIAccessor = NULL;
    }

/*
    if (NULL != pBuffer)
    {
        delete [] pBuffer;
        pBuffer = NULL;
    }
*/


    return hr;

}
 


Code: Select all  Expand view

HRESULT GetErrorMessage (LPTSTR lpszBuffer, int MaxBuffer)
{
    //  PURPOSE:  
    //      - Get the current error message
    //  PARAMETERS:
    //      - lpszOleDBErrMessage   :: Error message string buffer
    //  OPERATION:
    //      - ...
    //  RETURN VALUE:
    //      - HRESULT


    DWORD               dwErrorIndex   = 0;
    ULONG               ulNumErrorRecs = 0;
    HRESULT             hr = NOERROR;

    IErrorInfo          *pIErrorInfo;
    IErrorInfo          *pIErrorInfoRecord;
    IErrorRecords       *pIErrorRecords;
   
    ERRORINFO           ErrorInfo;


    // This interface supports returning error information
    // Get the error object from the system for this thread
    hr = GetErrorInfo(0, &pIErrorInfo);
    // Validation
    if(FAILED(hr) || NULL == pIErrorInfo)
        return hr;
 
    hr = pIErrorInfo->QueryInterface(IID_IErrorRecords, (void **) &pIErrorRecords);
    // Validation
    if(FAILED(hr) || NULL == pIErrorInfo)
        return hr;

    // Release unneeded interface
    pIErrorInfo->Release();
 
    // Determine the number of records in this error object
    hr = pIErrorRecords->GetRecordCount(&ulNumErrorRecs);
    // Validation
    if(FAILED(hr) || NULL == pIErrorInfo)
        return hr;

    // Loop over each error record in the error object to display information
    // about each error.  Errors are returned
    for (dwErrorIndex = 0; dwErrorIndex < ulNumErrorRecs; dwErrorIndex++)
    {
        // Attempt to retrieve basic error information for this error.
        hr = pIErrorRecords->GetBasicErrorInfo(dwErrorIndex, &ErrorInfo);
        // Retrieve standard error information for this error
        hr = pIErrorRecords->GetErrorInfo(dwErrorIndex, NULL, &pIErrorInfoRecord);
       
        // Allocate string buffer
        BSTR bstrDescriptionOfError = NULL;
        BSTR bstrSourceOfError = NULL;

        // Get error description
        hr = pIErrorInfoRecord->GetDescription(&bstrDescriptionOfError);
        // Get error source
        hr = pIErrorInfoRecord->GetSource(&bstrSourceOfError);

        if(NULL != pIErrorInfoRecord)
            // Release unneeded interface
            pIErrorInfoRecord->Release();
       
        // Initialize...
        memset(lpszBuffer, TEXT('\0'), MaxBuffer);

        // At this point, you could call GetCustomErrorObject
        // and query for additional interfaces to determine
        // what else happened.
        wsprintf(lpszBuffer,
                TEXT("Error Code: 0x%lx\r\n %s."),
                ErrorInfo.hrError,
                bstrDescriptionOfError);

        // Free the resources.
        SysFreeString(bstrDescriptionOfError);
        SysFreeString(bstrSourceOfError);
    }
 
    // Release unneeded interface
    pIErrorRecords->Release();

    return hr;
}

 


El archivo "SqlSvrCe.h"


Code: Select all  Expand view
//***********************************************************
//              SQL Server CE Interface Function           //
//                                                         //
//                     Author : Chris C                    //
//                    PassportONE.com                      //
//                http://www.PassportONE.com&nbsp;              //
//               Email:  chris@PassportONE.com             //
//                       © Aug 2002                        //
//                                                         //
//***********************************************************

#pragma once

// DO NOT REMOVE THE FOLLOWING DEFINE CONSTANT
#define OLEDBVER 0x210  // OLE DB driver version
#define DBINITCONSTANTS // Initialize OLE constants...
#define INITGUID        // ...once in each app.

// RELEVANT INCLUDE HEADER FILES
#include <windows.h>
#include <urlmon.h>
#include <oledb.h>
#include <oledberr.h>
#include <ssceoledb.h>
#include <coguid.h>
#include <Oaidl.h>          // Support OLE DB error lookup capability

// FOR LISTVIEW CONTROL ONLY, CAN BE REMOVE IS NOT
// APPLICABLE IN THE "ProcessRowset" FUNCTION.
#include <commctrl.h>



// -------------------------------------------------------
//
// SQL SERVER CE 2.0 DATABASE ACCESS GLOBAL VARIABLE
//
// -------------------------------------------------------

// Provider Interfaces
IDBInitialize       *pIDBInitialize      = NULL;
IUnknown            *pIUnknownSession    = NULL;

IDBCreateSession    *pIDBCreateSession   = NULL;
IDBProperties       *pIDBProperties      = NULL;

// SQL query command text handle object
IDBCreateCommand    *pIDBCrtCmd          = NULL;
ICommandText        *pICmdText           = NULL;


// -------------------------------------------------------
//
// SQL SERVER CE 2.0 DATABASE ACCESS GLOBAL VARIABLE
//
// -------------------------------------------------------

typedef struct tagTABLECOLOUMNINFO
{
    TCHAR   szTableName[32];    // Target table name
    TCHAR   szColumnName[32];   // New field name
    int     nColumnType;        // New field type
                                //    0 = int
                                //    1 = smallint
                                //    2 = tinyint
                                //    3 = bigint
                                //    4 = float
                                //    5 = nvarchar
                                //    6 = nchar
                                //    7 = bit
                                //    8 = datetime
                                //    9 = numeric
    int     nColumnSize;        // Field size
                                //    Only for the following data type
                                //     - nvarchar
                                //     - nchar
    BOOL    bIdentity;          // Identity field flag
                                //    TRUE  = Identity column
                                //    FALSE = Non-Identity column
    DWORD   dwIdentityProp;     // Identity Seed & Increment value
                                //    HIWORD = Identity seed;
                                //    LOWORD = Identity increment;
    BOOL    bAcceptNull;        // Accpet NULL flag
                                //    TRUE  = Accpet NULL string
                                //    FALSE = Not accpet NULL string
    BOOL    bPrimaryKey;        // Primaty Key flag
                                //    TRUE  = Primary key
                                //    FALSE = Non-primary key
    BOOL    bUnique;            // Unique flag
                                //    TRUE  = Unique
                                //    FALSE = Non-unique
    TCHAR   szPrimaryKeyName[32];// New prmary key name
} TABLECOLUMNINFO, FAR * LPTABLECOLUMNINFO;

typedef struct tagTABLEINDEXINFO
{
    TCHAR   szTableName[32];    // Target table name
    TCHAR   szIndexName[32];    // New Index name
    TCHAR   szIndexFields[64]// New Index fields
                                //    Example:
                                //      - Single Fields:
                                //          _tcscpy(szIndexName, TEXT("UserName"));
                                //      - Multiple Fields:
                                //          _tcscpy(szIndexName, TEXT("UserName, Password"));
    BOOL    bUnique;            // New Index is unique?
                                //    TRUE  = Unique index
                                //    FALSE = Non-Unique index
} TABLEINDEXINFO, FAR * LPTABLEINDEXINFO;


// -------------------------------------------------------
//
// SQL SERVER CE 2.0 DATABASE ACCESS FUNCTION
//
// -------------------------------------------------------

// Create a new SQL Server CE database provider.
HRESULT CreateSqlSvrCeProvider  (void);

// Create a new SQL Server CE database session right
// after successful connect to the pass in database
// name (*.sdf) in fullpath.
HRESULT CreateDBSession         (void);

// Retrieve the last known OLE DB error message, due to
// error occur through out the database access process.
HRESULT GetErrorMessage         (LPTSTR lpszBuffer, int MaxBuffer);

// Connect the SQL Server CE database with reference to
// the pass in database name (*.sdf) in fullpath.
HRESULT ConnectDB               (LPTSTR lpszDBName);

// Disconnect from the current open SQL Server CE database
// with reference to the pass in database name (*.sdf) in
// fullpath under the CreateDB/ConnectDB function.
HRESULT DisconnectDB            (LPTSTR lpszDBName);

// Create the SQL Server CE database with reference to
// the pass in database name (*.sdf) in fullpath.
HRESULT CreateDB                (LPTSTR lpszDBName);

// Delete the SQL Server CE database with reference to
// the pass in database name (*.sdf) in fullpath.
HRESULT DeleteDB                (LPTSTR lpszDBName);

// Compact the SQL Server CE database with reference to
// the pass in database name (*.sdf) in fullpath.
HRESULT CompactDB               (LPTSTR lpszDBName);

// Create new table with reference to
// the pass in table name and first column information
//    DUE TO SQL SERVER CE 2.0 MUST HAVE AT LEAST 1
//    COLUMN IN THE CREATED TABLE.
HRESULT CreateTable             (LPTABLECOLUMNINFO lptci);

// Delete the existing table with reference to
// the pass in table name..
HRESULT DropTable               (LPTSTR lpszTableName);

// Create new column with reference to
// the pass in information in TABLECOLUMNINFO structure.
HRESULT CreateColumn            (LPTABLECOLUMNINFO lptci);

// Drop the existing column with reference to
// the pass in information in TABLECOLUMNINFO structure.
HRESULT DropColumn              (LPTABLECOLUMNINFO lptci);

// Create new index with reference to
// the pass in information in TABLEINDEXINFO structure.
HRESULT CreateIndex             (LPTABLEINDEXINFO lptii);

// Drop the existing index with reference to
// the pass in information in TABLEINDEXINFO structure.
HRESULT DropIndex               (LPTABLEINDEXINFO lptii);

// Build the SQL92 command with reference to
// the pass in information in TABLEINDEXINFO structure.
HRESULT GetSQL92ColumnDef       (LPTABLECOLUMNINFO lptci, LPTSTR lpszBuffer, int nMaxBuffer);

// Execute the SQL Statement with does not require to
// return a RowSet object.
// EXAMPLE:
// SELECT, DELETE, CREATE TABLE, DROP TABLE, INSERT INTO & etc...
HRESULT ExecuteSQL              (LPTSTR lpszQuery);

// Load the records into a RowSet object with reference
// to the pass in SQL statement.
HRESULT GetRowset               (LPTSTR lpszQuery);

// Process the Rowset object created by the GetRowset function.
HRESULT ProcessRowset           (IRowset *pRowset);
 
Saludos
Salvador
Salvador
 
Posts: 144
Joined: Sun Dec 18, 2005 3:18 pm
Location: España

Re: Soporte de MySQL para FWPPC !!!

Postby Salvador » Fri Jun 05, 2009 2:53 pm

Antonio,

He añadido al fuente de arriba este código:
Code: Select all  Expand view
extern "C"
{
    LPWSTR AnsiToWide( LPSTR );
}

HB_FUNC( CONNECTDB )
{
  LPWSTR pW = AnsiToWide( hb_parc( 1 ) ) ;

  hb_retnl(ConnectDB( TEXT( "\\My Documents\\test.sdf" ) ) ) ; // asi devuelve S_OK
  //hb_retnl( ConnectDB( (LPTSTR) hb_parc(1) ) );
  //hb_retnl( ConnectDB( pW ) );
  //hb_xfree( pW );
}   

HB_FUNC( COINITIALIZEEX )
{   
    hb_retnl( CoInitializeEx( NULL, COINIT_MULTITHREADED ) );
}   

HB_FUNC( COUNINITIALIZE )
{
    CoUninitialize();
    hb_ret();
}   


Programa de test:
Code: Select all  Expand view
Function Main()
LOCAL cDatabase :="\\My Documents\\test.sdf"
  Msginfo( COINITIALIZEEX() )
  Msginfo( CONNECTDB( cDatabase ) ) // como parametro devuelve -2147467262 
Return nil


Las valores devueltos son S_OK, parece funcionar.
Pero no consigo pasar como LPTSTR la cadena con con el nombre de la base de datos.
Como puedo hacerlo.

Gracias.
Saludos
Salvador
Salvador
 
Posts: 144
Joined: Sun Dec 18, 2005 3:18 pm
Location: España

Re: Soporte de MySQL para FWPPC !!!

Postby Antonio Linares » Sun Jun 07, 2009 6:19 am

Salvador,

Desde PRG decláralo asi:

LOCAL cDatabase :="\My Documents\test.sdf"

y en C, lo tienes bien:
Code: Select all  Expand view

HB_FUNC( CONNECTDB )
{
  LPWSTR pW = AnsiToWide( hb_parc( 1 ) ) ;

  hb_retnl( ConnectDB( pW ) );
  hb_xfree( pW );
}  
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Soporte de MySQL para FWPPC !!!

Postby cyberkily » Fri Sep 13, 2013 4:09 pm

Hola buenas,

Quiero hacer pruebas acceciendo a SQLSRV, con fwppc 2007 y windows CE 6.0. No consigo compilar el .c con el .h. He añadido los dos trozos de c a un solo fichero SQLSVRCE.c y lo que puesto para compilar en el bat así:

%vcdir%\bin\clarm -W3 -c /DARM /DUNICODE /I%hdir%\include /I..\include SQLSVRCE.c

Está claro que lo estoy haciendo mal.¿Cómo podría hacerlo?

Gracias de antemano
Roberto Sánchez k:
cyberkily
 
Posts: 24
Joined: Fri Dec 05, 2008 11:20 pm

Re: Soporte de MySQL para FWPPC !!!

Postby Antonio Linares » Fri Sep 13, 2013 4:30 pm

Roberto,

Que errores te aparecen al compilar ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Soporte de MySQL para FWPPC !!!

Postby cyberkily » Sat Sep 14, 2013 6:38 am

Antonio,

Lo que hice fue coger el código de Salvador, uní los dos fragmentos de código en un fichero .c llamado sqlsrvce.c, cree su .h el cuál lo he situado donde tengo los prg y esta es la lista de errores que me da.

Code: Select all  Expand view

SqlSvrCe.c
d:\vce\include\arm\ssceoledb.h(83) : error C2061: syntax error : identifier 'ISSCECompact'
d:\vce\include\arm\ssceoledb.h(83) : error C2059: syntax error : ';'
d:\vce\include\arm\ssceoledb.h(83) : error C2059: syntax error : ':'
d:\vce\include\arm\ssceoledb.h(95) : error C2061: syntax error : identifier 'IRowsetPosition'
d:\vce\include\arm\ssceoledb.h(95) : error C2059: syntax error : ';'
d:\vce\include\arm\ssceoledb.h(95) : error C2059: syntax error : ':'
d:\pocketpc\apSQLSRV\sqlsvrce.c(35) : error C2065: 'CLSID_SQLSERVERCE_2_0' : undeclared identifier
d:\pocketpc\apSQLSRV\sqlsvrce.c(35) : warning C4047: 'function' : 'const struct _GUID *const ' differs in levels of indirection from 'int '
d:\pocketpc\apSQLSRV\sqlsvrce.c(35) : warning C4024: 'CoCreateInstance' : different types for formal and actual parameter 1
d:\pocketpc\apSQLSRV\sqlsvrce.c(38) : error C2115: 'function' : incompatible types
d:\pocketpc\apSQLSRV\sqlsvrce.c(38) : warning C4024: 'CoCreateInstance' : different types for formal and actual parameter 4
d:\pocketpc\apSQLSRV\sqlsvrce.c(58) : error C2039: 'QueryInterface' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'd:\pocketpc\apSQLSRV\sqlsvrce.c(63) : error C2039: 'AddRef' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(66) : error C2039: 'CreateSession': is not a member of 'IDBCreateSession'
        d:\vce\include\arm\oledb.h(7567) : see declaration of 'IDBCreateSession'

d:\pocketpc\apSQLSRV\sqlsvrce.c(73) : error C2039: 'QueryInterface' : is not a member of 'IUnknown'
        d:\vce\include\arm\unknwn.h(133) : see declaration of 'IUnknown'
d:\pocketpc\apSQLSRV\sqlsvrce.c(78) : error C2039: 'AddRef' : is not a member of 'IUnknown'
        d:\vce\include\arm\unknwn.h(133) : see declaration of 'IUnknown'
d:\pocketpc\apSQLSRV\sqlsvrce.c(81) : error C2039: 'CreateCommand': is not a member of 'IDBCreateCommand'
        d:\vce\include\arm\oledb.h(7465) : see declaration of 'IDBCreateCommand'

d:\pocketpc\apSQLSRV\sqlsvrce.c(138) : error C2039: 'QueryInterface' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(144) : error C2039: 'AddRef' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(147) : error C2039: 'SetProperties' : is not a member of 'IDBProperties'
        d:\vce\include\arm\oledb.h(7821) : see declaration of 'IDBProperties'
d:\pocketpc\apSQLSRV\sqlsvrce.c(157) : error C2039: 'Initialize' :is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(188) : error C2039: 'Release' : is not a member of 'IDBCreateSession'
        d:\vce\include\arm\oledb.h(7567) : see declaration of 'IDBCreateSession'

d:\pocketpc\apSQLSRV\sqlsvrce.c(194) : error C2039: 'Release' : is not a member of 'IUnknown'
        d:\vce\include\arm\unknwn.h(133) : see declaration of 'IUnknown'
d:\pocketpc\apSQLSRV\sqlsvrce.c(200) : error C2039: 'Release' : is not a member of 'IDBProperties'
        d:\vce\include\arm\oledb.h(7821) : see declaration of 'IDBProperties'
d:\pocketpc\apSQLSRV\sqlsvrce.c(206) : error C2039: 'Release' : is not a member of 'IDBCreateCommand'
        d:\vce\include\arm\oledb.h(7465) : see declaration of 'IDBCreateCommand'

d:\pocketpc\apSQLSRV\sqlsvrce.c(212) : error C2039: 'Release' : is not a member of 'ICommandText'
        d:\vce\include\arm\oledb.h(6889) : see declaration of 'ICommandText'
d:\pocketpc\apSQLSRV\sqlsvrce.c(219) : error C2039: 'Release' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(273) : error C2039: 'QueryInterface' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'

d:\pocketpc\apSQLSRV\sqlsvrce.c(279) : error C2039: 'AddRef' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
       
d:\pocketpc\apSQLSRV\sqlsvrce.c(282) : error C2039: 'CreateDataSource' : is not a member of 'IDBDataSourceAdmin'
        d:\vce\include\arm\oledb.h(8310) : see declaration of 'IDBDataSourceAdmin'

d:\pocketpc\apSQLSRV\sqlsvrce.c(305) : error C2039: 'Release' : is not a member of 'IDBDataSourceAdmin'
        d:\vce\include\arm\oledb.h(8310) : see declaration of 'IDBDataSourceAdmin'

d:\pocketpc\apSQLSRV\sqlsvrce.c(356) : error C2065: 'ISSCECompact': undeclared identifier
d:\pocketpc\apSQLSRV\sqlsvrce.c(356) : error C2065: 'pISSCECompact' : undeclared identifier
d:\pocketpc\apSQLSRV\sqlsvrce.c(356) : warning C4047: '=' : 'int 'differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(356) : error C2106: '=' : left oper and must be l-value
d:\pocketpc\apSQLSRV\sqlsvrce.c(387) : error C2039: 'QueryInterface' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(393) : error C2039: 'AddRef' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(396) : error C2039: 'SetProperties' : is not a member of 'IDBProperties'
        d:\vce\include\arm\oledb.h(7821) : see declaration of 'IDBProperties'
d:\pocketpc\apSQLSRV\sqlsvrce.c(406) : error C2039: 'Initialize' : is not a member of 'IDBInitialize'
        d:\vce\include\arm\oledb.h(7965) : see declaration of 'IDBInitialize'
d:\pocketpc\apSQLSRV\sqlsvrce.c(409) : error C2039: 'QueryInterface' : is not a member of 'IDBProperties'
        d:\vce\include\arm\oledb.h(7821) : see declaration of 'IDBProperties'
d:\pocketpc\apSQLSRV\sqlsvrce.c(415) : error C2039: 'AddRef' : is not a member of 'IDBProperties'
        d:\vce\include\arm\oledb.h(7821) : see declaration of 'IDBProperties'
d:\pocketpc\apSQLSRV\sqlsvrce.c(434) : error C2223: left of '->Compact' must point to struct/union
d:\pocketpc\apSQLSRV\sqlsvrce.c(438) : error C2223: left of '->Release' must point to struct/union
d:\pocketpc\apSQLSRV\sqlsvrce.c(439) : warning C4047: '=' : 'int 'differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(445) : error C2065: 'false' : undeclared identifier
d:\pocketpc\apSQLSRV\sqlsvrce.c(484) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(485) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(512) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(536) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(537) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(564) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(588) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(589) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(622) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(648) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(649) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(650) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(651) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(652) : warning C4047: 'initializing' : 'unsigned short ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(768) : error C2039: 'SetCommandText' : is not a member of 'ICommandText'
        d:\vce\include\arm\oledb.h(6889) : see declaration of 'ICommandText'
d:\pocketpc\apSQLSRV\sqlsvrce.c(774) : error C2039: 'Execute' : is not a member of 'ICommandText'
        d:\vce\include\arm\oledb.h(6889) : see declaration of 'ICommandText'
d:\pocketpc\apSQLSRV\sqlsvrce.c(807) : error C2039: 'CreateCommand' : is not a member of 'IDBCreateCommand'
        d:\vce\include\arm\oledb.h(7465) : see declaration of 'IDBCreateCommand'

d:\pocketpc\apSQLSRV\sqlsvrce.c(815) : error C2039: 'SetCommandText' : is not a member of 'ICommandText'
        d:\vce\include\arm\oledb.h(6889) : see declaration of 'ICommandText'
d:\pocketpc\apSQLSRV\sqlsvrce.c(822) : error C2039: 'Execute' : is not a member of 'ICommandText'
        d:\vce\include\arm\oledb.h(6889) : see declaration of 'ICommandText'
d:\pocketpc\apSQLSRV\sqlsvrce.c(839) : error C2039: 'Release' : is not a member of 'IRowset'
        d:\vce\include\arm\oledb.h(2782) : see declaration of 'IRowset'
d:\pocketpc\apSQLSRV\sqlsvrce.c(845) : error C2039: 'Release' : is not a member of 'ICommandText'
        d:\vce\include\arm\oledb.h(6889) : see declaration of 'ICommandText'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1177) : error C2039: 'QueryInterface' : is not a member of 'IErrorInfo'
        d:\vce\include\arm\oaidl.h(5240) : see declaration of 'IErrorInfo'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1183) : error C2039: 'Release' : is not a member of 'IErrorInfo'
        d:\vce\include\arm\oaidl.h(5240) : see declaration of 'IErrorInfo'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1186) : error C2039: 'GetRecordCount' : is not a member of 'IErrorRecords'
        d:\vce\include\arm\oledb.h(10905) : see declaration of 'IErrorRecords'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1196) : error C2039: 'GetBasicErrorInfo' : is not a member of 'IErrorRecords'
        d:\vce\include\arm\oledb.h(10905) : see declaration of 'IErrorRecords'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1198) : error C2039: 'GetErrorInfo' : is not a member of 'IErrorRecords'
        d:\vce\include\arm\oledb.h(10905) : see declaration of 'IErrorRecords'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1201) : error C2275: 'BSTR' : illegal use of this type as an expression
        d:\vce\include\arm\wtypes.h(1111) : see declaration of 'BSTR'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1201) : error C2146: syntax error : missing ';' before identifier 'bstrDescriptionOfError'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1201) : error C2065: 'bstrDescriptionOfError' : undeclared identifier
d:\pocketpc\apSQLSRV\sqlsvrce.c(1201) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1202) : error C2275: 'BSTR' : illegal use of this type as an expression
        d:\vce\include\arm\wtypes.h(1111) : see declaration of 'BSTR'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1202) : error C2146: syntax error : missing ';' before identifier 'bstrSourceOfError'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1202) : error C2065: 'bstrSourceOfError' : undeclared identifier
d:\pocketpc\apSQLSRV\sqlsvrce.c(1202) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1205) : error C2039: 'GetDescription' : is not a member of 'IErrorInfo'
        d:\vce\include\arm\oaidl.h(5240) : see declaration of 'IErrorInfo'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1207) : error C2039: 'GetSource' :is not a member of 'IErrorInfo'
        d:\vce\include\arm\oaidl.h(5240) : see declaration of 'IErrorInfo'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1211) : error C2039: 'Release' : is not a member of 'IErrorInfo'
        d:\vce\include\arm\oaidl.h(5240) : see declaration of 'IErrorInfo'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1225) : warning C4047: 'function' : 'unsigned short *' differs in levels of indirection from 'int '
d:\pocketpc\apSQLSRV\sqlsvrce.c(1225) : warning C4024: 'SysFreeString' : different types for formal and actual parameter 1
d:\pocketpc\apSQLSRV\sqlsvrce.c(1226) : warning C4047: 'function' : 'unsigned short *' differs in levels of indirection from 'int '
d:\pocketpc\apSQLSRV\sqlsvrce.c(1226) : warning C4024: 'SysFreeString' : different types for formal and actual parameter 1
d:\pocketpc\apSQLSRV\sqlsvrce.c(1230) : error C2039: 'Release' : is not a member of 'IErrorRecords'
        d:\vce\include\arm\oledb.h(10905) : see declaration of 'IErrorRecords'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1235) : error C2059: syntax error : 'string'
d:\pocketpc\apSQLSRV\sqlsvrce.c(1242) : warning C4013: 'AnsiToWide' undefined; assuming extern returning int
d:\pocketpc\apSQLSRV\sqlsvrce.c(1242) : warning C4013: 'hb_parc' undefined; assuming extern returning int
d:\pocketpc\apSQLSRV\sqlsvrce.c(1242) : warning C4047: 'initializing' : 'unsigned short *' differs in levels of indirection from 'int '
d:\pocketpc\apSQLSRV\sqlsvrce.c(1244) : warning C4013: 'hb_retnl' undefined; assuming extern returning int
d:\pocketpc\apSQLSRV\sqlsvrce.c(1245) : warning C4013: 'hb_xfree' undefined; assuming extern returning int
d:\pocketpc\apSQLSRV\sqlsvrce.c(1249) : error C2084: function 'int__cdecl HB_FUNC()' already has a body
d:\pocketpc\apSQLSRV\sqlsvrce.c(1250) : warning C4013: 'CoInitializeEx' undefined; assuming extern returning int
d:\pocketpc\apSQLSRV\sqlsvrce.c(1250) : error C2065: 'COINIT_MULTITHREADED' : undeclared identifier
d:\pocketpc\apSQLSRV\sqlsvrce.c(1256) : warning C4013: 'hb_ret' undefined; assuming extern returning int
 


//-----------------------------------------------
Me da error en vce\include\SSCEOLEDB.h que no he modificado, su fecha es de 04/2003. A lo mejor no tengo el fichero adecuado.

Gracias de Antemano
Roberto Sánchez k:
cyberkily
 
Posts: 24
Joined: Fri Dec 05, 2008 11:20 pm

Re: Soporte de MySQL para FWPPC !!!

Postby Antonio Linares » Sat Sep 14, 2013 8:22 am

Roberto,

Parece que ISSCECompact está definido en sqlce_oledb.h

Estas incluyendo ese fichero en tu fichero en C ?
#include <sqlce_oledb.h>
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 9 guests