MFC ODBC

Hi all,
I want to access the MFC MySQL DB via ODBC to make some reports.
I already got username/pw.
The problem is that I can only access message_tracker db from the server wherer MFC is installed. When I access from a different server I can only access the information_scheme.
Any hints what I can do?
Thanks in advance.

It's just mysql so you can start it with --skip-grant-tables, log in as root and update the users table so that remote logins are allowed.
I did this to generate some custom reports as well. It's a bit overkill in my case, but its easier than writing your own log parser. It would be nice to have a parsing library that everyone could reuse for their scripts :)

Similar Messages

  • MFC application with Sql Server Database

    Hello!
    I have made an application (using MFC ODBC costumer) and i want to make this program run in every computer.
    Is there any way to run it without installing sql server in every computer?
    Thank you!

    You don't need to install sql server in every computer as its available with MS OS. You can create a User DNS with of your database in every computer  that will be connected with your application as you may be sharing a common database.
    Step 1: Create link of your database (say data.mdb) in all computers . You can use mklink command. 
    Step 2: Goto  Control Panel\All Control Panel Items\Administrative Tools and open ODBC Data Source Administrator                    and register a UserDNS
    with the database (data.mdb)

  • Migrating Existing ODBC based Application

    I have an application that uses MFC/ODBC to connect to MS Access 97. I am looking into migrating it to an Oracle Backend.
    Whats the best way/practise for such an effort.
    What does it entail?

    Oracle has a product called the Oracle Migration Workbench that would be useful in migrating the database backend. The MFC application should mostly work without significant changes-- it's mostly a matter of testing to figure out what the Access ODBC driver does differently than the Oracle ODBC driver and what impact that has on your application.
    Once the application functionality is migrated, you'll hopefully have a large chunk of schedule to optimize your code & refactor your queries to take advantage of Oracle. This is the biggest hurdle in my eyes-- there are lots of things that work really well against 1 database that perform or scale poorly on another database.
    Justin

  • ODBC Driver V8.00.58.00 Error

    Hi
    I am experimenting an Oracle ODBC error while selecting more than 2500 records from a database table.
    Does anyone known the cause of the error?
    Thanks in advance.
    ==== ENVIRONMENT DESCRIPTION ====
    The database server is ORACLE Version 8.0.5.2.1
    My database table has the following structure:
    CREATE TABLE MY_TABLE
    PK_PKEY NUMBER(9) NOT NULL ,
    FK_FKEY1 NUMBER(9) NOT NULL ,
    FK_FKEY2 NUMBER(5) NOT NULL ,
    FIELD1 NUMBER(1) NOT NULL ,
    FIELD2 NUMBER(5) NOT NULL ,
    CONSTRAINT MY_TABLE_FILED1 CHECK(FIELD1 BETWEEN 0 AND 1),
    CONSTRAINT PK_MY_TABLE_KEY PRIMARY KEY (PK_PKEY)
    The table is populated with 3000 records where FIELD1 is always equal to 1 (this value is relevant for the queries).
    The application that executes the queries to the table is written in Visual C++ 6.0, the database connection is made through ODBC datasouce using the MFC ODBC database classes (CDatabase and CRecordset).
    The Oracle client installed to access the database server is from version: ORACLE ODBC driver - Version 8.00.58.00 - Oracle Corporation SQORA32.DLL 1/5/00.
    The SQL queries executed in the application are:
    QUERY1: SELECT pk_pkey FROM my_table
    QUERY2: SELECT pk_pkey FROM my_table where FIELD1=1
    QUERY3: SELECT pk_pkey FROM my_table where FIELD1=1 ORDER BY pk_pkey
    The C++ application only creates a CDatabase object (m_cDatabase.OpenEx((LPCTSTR)_T(DSN=tc1;UID=myuser;PWD=mypwd))) and a CRecordset object with the previous created database connection. The queries are executed using a simple procedure described in the end of the email.
    I test several combinations using the queries described above and the results are quite different. The combinations performed where:
    TEST1 - First QUERY2 then QUERY3 RESULT 1
    TEST2 - First QUERY1 then QUERY3 RESULT 1
    TEST3 - First QUERY3 then QUERY2 RESULT 2
    TEST4 - First QUERY3 then QUERY1 RESULT 1
    TEST5 - First QUERY1 then QUERY2 RESULT 1
    TEST6 - First QUERY2 then QUERY1 RESULT 3
    TEST7 - First QUERY1 then QUERY1 RESULT 3
    TEST8 - First QUERY2 then QUERY2 RESULT 3
    TEST9 - First QUERY3 then QUERY3 RESULT 3
    == RESULT DESCRIPTIONS ==
    - RESULT 1
    The first query is executed successfully but the application catches a database exception when executing the second query.
    Database Exception: Restricted data type attribute violation
    State: 07006, Native:0, Origin:[ORACLE][ODBC]
    - RESULT 2
    The first query is executed successfully but the application crash while executing the second query.
    The application does not catch any database exception.
    The crash description is:
    Unhanded exception Application.exe (SQORA32.DLL):0xC0000005 Access Violation
    - RESULT 3
    The queries returned the expected results. No errors where reported.
    ==== END OF ENVIRONMENT DESCRIPTION ====
    *** VERY IMPORTANT NOTE ***
    1. Each test generates a log file where it is possible to confirm the results of the tests.
    2. Another element is that the number of times the first query is consecutive executed before the second one does not influence the result of the tests.
    3. The error is reported always after the 2500 record is fetch.
    4. I executed exactly the same test where the only modification was the version of the ODBC driver used in the client and the tests ran successfully. The results are correct if the client driver is one of the following:
    ORACLE ODBC driver - Version 8.01.05.00 - Oracle Corporation SQORA32.DLL 16/02/1999
    ORACLE ODBC driver - Version 8.00.05.00 - Oracle Corporation SQORA32.DLL 06/12/1998
    5. I also executed the tests with the ORACLE ODBC driver version 8.00.59.00 and the results where the same as from driver v8.00.58.00
    6. If I create a restriction in the queries to return less than 2500 records the test are performed successful in all drivers.
    == PROCEDURE ==
    All the queries are executed in a simple procedure like:
    bool CTesteDBDlg::ExecuteTeste(void)
    int nIndex = 1;
    CString strSQL;
    CString strText;
    try
    CRecordset cRecordset(&m_cDatabase);
    strSQL.Format(_T("SELECT pk_pkey FROM my_table"));
    //strSQL.Format(_T("SELECT pk_pkey FROM my_table WHERE field1=1"));
    //strSQL.Format(_T("SELECT pk_pkey FROM my_table WHERE field1=1 ORDER BY pk_pkey"));
    if(!cRecordset.Open(CRecordset::snapshot, (LPCTSTR)strSQL,
    CRecordset::readOnly))
    return false;
    CString strDBValue;
    while(!cRecordset.IsEOF())
    cRecordset.GetFieldValue((int)0, strDBValue);
    LOG_DEBUG_MESSAGE(eLow,(_T("ExecuteTeste1: Index=%ld - Value=%s"), nIndex, strDBValue));
    nIndex++;
    cRecordset.MoveNext();
    catch(CDBException* pDBException)
    TCHAR szCauze[256];
    pDBException->GetErrorMessage(szCauze, 255);
    LOG_DEBUG_MESSAGE(eLow,(_T("Database Exception: Code=%d - Desc = %s"), pDBException->m_nRetCode, szCauze));
    return false;
    return true;
    null

    Mr. Cordeiro sent me the project and data he's using. When I run the test program on my 8.0.6 client machine with the 8.0.6 ODBC driver, I see no failures. When I run the test program on my 8.1.6 client machine with the 8.1.6.1 driver, however, I see the problems Mr. Cordeiro describes. If I install the current evelopment build of our 8.1.6 driver, however, the problems disappear. Unfortunately, I don't have an 8.0.5 client machine to test on right now.
    I suspect that the problem here has been identified previously, has already been fixed, and will be shipped with the next release of the driver.
    My only hesitation here is that the 8.0.5.8 and 8.0.6.0 ODBC drivers are identical code, just linked with different client libraries, so it's unclear why the 8.0.6 client is working while the 8.0.5 client, apparently, is failing. It is possible that there is/was a bug in one of the layers under the ODBC driver which is causing the problem and that different versions of our code hit or miss this problem. I would strongly suggest that you apply the latest Oracle patch kit for your client (i.e. 8.0.5.2.6 for the 8.0.5 client) to see if that fixes your problem. These patch kits are available from the Oracle FTP site-
    ftp://oracle-ftp.oracle.com/server/patchsets/wgt_tech/server/windowsNT/
    Justin Cave
    ODBC Development

  • How to get both, the ResultSet and Output (return value) from Oracle Stored Procedure

    Hi! I am doing a conversion from MSSQL to Oracle with C++ and MFC ODBC. Any comment is appreciated!! I have Oracle 8i and Oracle ODBC 8.1.6 installed.
    My question is how to retrieve the return value AND ALSO the resultSet at the same time by using Oracle function without modifying my souce codes (except puttting mypackage. string infron of my procedure name, see below).
    -- My source code in C++ with MSSQL ....
    sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    Where CustoemrList is a Crecordset object...
    IN DoFieldExchange(CFieldExchange* pFX) I have ...
    //{{AFX_FIELD_MAP(CQOSDB_Group)
    pFX->SetFieldType(CFieldExchange::outputColumn);
    RFX_Long(pFX, T("Name"), mCustoemrName);
    //}}AFX_FIELD_MAP
    // output parameter
    pFX->SetFieldType( CFieldExchange::outputParam );
    RFX_Int( pFX, T("IndexCount"), mCustomerNumber);
    -- m_CustomerNumber is where i store the return value!!!
    -- In Oracle Version, i have similar codes with ...
    sqlStr.Format("{? = call mypackage.ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    -- I have oracle package/Body codes as following...
    create or replace package mypackage
    as
    type group_rct is ref cursor;
    Function listgroups(
    nameID NUMBER ,
    RC1 IN OUT Mypackage.group_rct ) return int;
    end;
    Create or replace package body mypackage
    as
    Function listgroups(
    NameID NUMBER ,
    RC1 IN OUT Mypackage.group_rct )return int
    IS
    BEGIN
    OPEN RC1 FOR SELECT Name
    from Customer
    WHERE ID = NameIDEND ListGroups;
    END
    return 7;
    END listgroups;
    END MyPackage;
    Ive simplified my codes a bit....
    null

    yes, it is exactly what i want to do and I am using Oracle ODBC driver.
    I tried using procedure with 1 OUT var fo numeric value and the other IN OUT ref cursor var instead of function, but error occurs when I called it from the application. It give me a memory ecxception error!!
    sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    it seems to me that the ? marker var is making all the trouble... can you please give me any more comment on this?? thanks!
    null

  • System DSN setup

    I installed Oracle8i Enterprise Server 8.1.6 Release 2 on W2K Advanced Server. I logged in to SQLPlus as system/manager and created a single table (Userid). I am using Oracle ODBC Driver 8.01.06.00 (must have been installed with the 8i Enterprise Edition?)From the trace it is clear that it is not picking up the password. The error is "ORA-01005 - null password given;logon denied". But I have configured the ODBC System DSN setup with Service name=o8ibegin and UserID=system/manager and Data Source Name=SiLicBkr. My IIS (ISAPI DLL) application uses MFC Odbc Classes with DSN=SiLicBkr and works fine with MS SQL Server and MS ACCESS. Any one can tell me where and how the password should be specified to the Oracle ODBC driver? Obviously being IIS app, password prompting at connect time is not an option!
    Thanks,
    Ganesh ([email protected])

    Hi Justin, thanks for the prompt reply. I am still having problems with your first suggestion (I did not try the second option to do with registry). You mention a 'connect string', I assume this is to be entered in the Service field (because it does not accept such a string in Data Source Name field)? I have SiLicBkr in Data Source Name field, system in UserID field and I have tried different things for the Service Name field such as "DBQ=o8ibegin;PWD=manager" and also "DBQ=o8ibegin;PWD=manager;DSN=SiLicBkr". You may note, in your reply you missed out the service name "o8ibegin" altogether. After talking to others, I was told to try DBQ=o8ibegin in the connect string as shown above for service name. Now I get ORA-12154 TNS could not resolve service name...error. I may also mention, others told me to use Net Easy .. to specify connect string, but the closest thing I have is Net8 configuration assistant and while it shows o8ibegin, it does not provide any way for me to specify the connect string you mentioned! Any help will be appreciated. I have carefully looked at your online help in the ODBC administration setup, but not much luck.
    Thanks,
    Ganesh([email protected])
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Justin Cave ([email protected]):
    The UserID field in the Driver Setup screen should be just the userid (system), not the userid/password (system/mananger)
    There are two ways to specify the password. First, your connect string can be "DSN=SiLicBkr;PWD=manager".
    Second, you can add a registry entry "Password" with the string value "manager" at \\HKEY_LOCAL_MACHINE\SOFTWARE\odbc\ODBC.INI\SiLicBkr\. Obviously, the former is the preferred solution.
    It has been our feeling that allowing the password to be specified in the driver setup is generally a poor decision because of the security considerations. Since anyone at the machine can view the DSN configuration, exposing the password could allow users much more access to data than intended. Passwords that are compiled as part of an application, on the other hand, are much more difficult to achieve.
    Justin Cave
    ODBC Development<HR></BLOCKQUOTE>
    null

  • Oracle ODBC Driver 8.1.7.8b causing MFC OpenEx() delay

    Hi:
    I have installed the Oracle ODBC Driver version 8.1.7.8b on a WINNT 4.0 Workstation with SP6a. I have an MFC test app with the following code:
    PostStatus(ERROR_NOERROR, APP_NAME, "Calling OpenEx()");
    CDatabase db;
    if(db.OpenEx(_T("DSN=MYTESTDSN;UID=USERID;PWD=PASSWORD"), CDatabase::openReadOnly|CDatabase::noOdbcDialog))
         PostStatus(ERROR_NOERROR, APP_NAME, "OpenEx() success,calling Close()");
         db.Close();
    } // OpenEx()
    else // OpenEx() error
         PostStatus(ERROR_MODERATE, APP_NAME, "Error opening database,OpenEx() failed!");
    The above OpenEx call is taking upto 3 seconds to return. When I use Microsoft Oracle ODBC driver, it takes less than 0.5 sec to connect/disconnect.
    Any idea why OpenEx() is taking that long? I've compiled this using VC++ 6.0 SP5, on a WIN2K and WINNT system but I get the same result.
    Thanks,
    Amit.

    This forum is for feedback about the OTN program and problems with OTN accounts. Technical questions cannot be answered here. Please post your question in the appropriate product or technology forum. http://forums.oracle.com/forums/index.jsp?cat=48

  • ODBC / MFC: Numbers are mapped to String

    Somebody else had a comparable problem a few months ago, but so far I found no solution.
    We have fields in the database defined as number(11). When we read them via ODBC (using the latest Oracle ODBC driver) in Visual C++ 6.0 (service pack 4) with CRecordSet it is mapped to CString instead to a long.
    Here a code example:
    CRecordset SzName(&DB);
    CString SQLQueryText;
    CDBVariant varValue;
    SQLQueryText.Format("SELECT * FROM ACTION");
    SzName.Open(CRecordset::forwardOnly, _T(SQLQueryText), CRecordset::readOnly);
    SzName.GetFieldValue("STATE",varValue);
    STATE is defined as number(11) and varValue interprets it as a string!
    Any ideas how to solve this problem?
    Thank you very much for your help.
    -- Frank

    You can go into the MFC Wizard generated code and manually change the RFX_ field exchange to Doubles/Floats and it will work.

  • Error calling stored procedure from MFC using odbc

    Hello,
    I am using MFC to call a stored procedure written in PL/SQL, but when I make the call I get the next error in Spanish:
    "No se enlazaron columnas antes de llamar a SQLFetchScroll o SQLExtendedFetch", which more or less in English means:
    "No rows were binded before calling SQLFetchScroll or SQLExtendedFetch".
    I am using a CRecordset derived class to access the stored procedure. I am unable to find the error.
    THE STORED PROCEDURE'S HEADER:
    Sp_Int_Ot_Ordendetrabajoalta ( lineatrabajo NUMBER, lv_orden NUMBER, usuario
    VARCHAR2, idvehiculo NUMBER, fechamax1 VARCHAR2, resumen VARCHAR2, detalle
    VARCHAR2,
    coderp VARCHAR2, numtrabrecibidos NUMBER, lv_CODOT VARCHAR2, retorno OUT
    INTEGER)
    THE .H FOR THE CRECORDSET DERIVED CLASS (Visual Studio 6 comments removed)
    class CRecSP : public CRecordset
    public:
    CRecSP(CDatabase* pDatabase = NULL);
    DECLARE_DYNAMIC(CRecSP)
    CString m_szSQL;
    long m_RETORNO;
    virtual CString GetDefaultConnect();
    virtual CString GetDefaultSQL();
    virtual void DoFieldExchange(CFieldExchange* pFX);
    THE .CPP FOR THE CLASS (VS6 comments removed)
    IMPLEMENT_DYNAMIC(CRecSP, CRecordset)
    CRecSP::CRecSP(CDatabase* pdb) : CRecordset(pdb)
    m_RETORNO = 0;
    m_nParams = 1;
    m_nDefaultType = snapshot;
    CString CRecSP::GetDefaultConnect()
    return T( DBCONNECTION_STRING );
    CString CRecSP::GetDefaultSQL()
    return m_szSQL;
    void CRecSP::DoFieldExchange(CFieldExchange* pFX)
    pFX->SetFieldType(CFieldExchange::outputParam);
    RFX_Long(pFX, _T("[retorno]"), m_RETORNO );
    USING THE CRECORDSET DERIVED CLASS: (Vars read from EditBoxes as CStrings
    and formatted in the SQL)
    CRecSP *rec = new CRecSP(&db);
    szSQL.Format( "{CALL
    FGROT2005.SP_INT_OT_ORDENDETRABAJOALTA(%s,%s,'%s',%s,'%s','%s','%s','%s',%s,'%s',?)}",
    szLinea, szOrden, "USER", szIdVeh, szFechaMax, szResumen,
    szDetalle, "ERP", "0", szCodOT
    rec->m_szSQL = szSQL;
    //rec->Open( CRecordset::forwardOnly,szSQL,CRecordset::readOnly );
    rec->Open( );
    iError = rec->m_RETORNO;
    rec->Close();

    This forum is meant for discussions about OTN content/site and services.
    Questions about Oracle products and technologies will NOT be answered in this forum. Please post your product or technology related questions in the appropriate product or technology forums, which are monitored by Oracle product managers.
    Product forums:
    http://forums.oracle.com/forums/index.jsp?cat=9
    Technology forums:
    http://forums.oracle.com/forums/index.jsp?cat=10

  • Oracle 8 and 8i ODBC drivers

    I have written a win32 client application with Visual C++ for accessing an oracle 8.0.5 server on a linux platform.I have used an ODBC connection (MFC classes CDatabase e CRecordset). In application I have used a recordset on a view for updating the view's base table. On a view I have defined an instead of update trigger. All works fine. Now I must migrating it on an oracle 8.1.7 oracle server (or on win2k or linux). End now start the problem. On 8i server, after executing the query on the view, the function SQLGetStmtOption with SQL_CONCURRENCY param return SQL_CONCUR_READ_ONLY, making the recordset read only and i don't modify the view. What's the differences between Oracle 8 and Oracle 8i ODBC driver? Why with Oracle 8i I don't modify a view?
    null

    Executed query is
    SELECT * FROM VIEW_NAME WHERE ID = value
    where ID is a primary key of the only key preserving table of the view.

  • How can I say to the ODBC Driver to ignore the double quotes (")

    I have an application that does many SELECT's to the DB, but there is no predifined case, i.e. some developers do the commands in lowercase while others do it on uppercase.
    I'm trying to solve this in the easy way, i.e. I'm trying to find a way to say to the ODBC driver: Whenever you see SELECT "column_name" from "table_name" or SELECT "COLUMN_NAME" from "TABLE_NAME", please ignore the double quotes so that these commands won't be different to the Oracle DB.
    Is there a way to do this?
    I don't want to change AAALLLL the classes. It would take me weeks.
    Thanks in advance.

    OK, thanks.
    I'm trying another approach... is it possible to ask the driver to reply a space instead of double quotes in
    ::SQLGetInfo(...,SQL_IDENTIFIER_QUOTE_CHAR)???
    That function is called on the MFC's (Microsoft Foundation Classes) in dbcore.cpp --> CDatabase::GetConnectInfo
    If it is possible to change the answer from this function (SQLGetInfo) it would solve me all my problems.

  • Instantclient 11.2.0.3 on Windows XP (x86) ODBC Error

    Greetings,
    Trying to deploy instantclient 11.2.0.3 w/ODBC on Windows XP.
    Unzipped files to c:\oracle\instantclient_11_2.
    Ran odbc_install.exe.
    Added c:\oracle\instantclient_11_2 to path.
    Created/set TNS_ADMIN environment variable.
    Reboot
    Running windows ODBC Data Source Administrator to add Oracle data source gives following error:
    "The setup routines for the Oracle in instantclient_11_2 ODBC driver could not be loaded due to system error code 14001."
    Click OK. Next dialog box says:
    "Could not load the setup or translator library."
    Any ideas?
    The instantclient 11.2.0.1 distribution works fine with the same setup procedure. I'm not new to instantclient--been using it for at least a year with great success. Just trying to use the latest version of the instantclient software on this computer. I also notice that the 11.2.0.1 base distribution includes a number of dll files that are not included with the 11.2.0.3 base distribution. These include a number of mfc*.dll and msv*.dll files. Does instantclient no longer support XP installs as of the 11.2.0.3 release? Did Oracle forget to include a bunch of dll files in the base 11.2.0.3 window x86 distribution? Did the deployment procedure change between 11.2.0.1 and 11.2.0.3? Am I installing 11.2.0.3 incorrectly?
    We can fall back to the 11.2.0.1 distribution temporarily. But I'd like to get the newest 11.2.0.3 distribution working for our XP computers.
    Thank you for your assistance.
    Griffith

    Hi,
    I've no idea about the reason but I can confirm that the latest Instant Client Version is not supported by XP.
    I've tried a win7 install and evrything works fine with 11.2.0.3.0 version;
    on XP I need to use 11.2.0.1.0 version.
    Marco

  • MFC based apllication and row LOCK.

    Dear Oracle Tech.
    As end user of Oracle Database, we seek advise from Oracle on the following issue: our business application is an Windows system (MFC based) built with Visual Studio 6; Our database is Oracle 9i;
    We have a database resources shared by many users that connect in ODBC way. We would like to have that when ever some one is using
    (modifing, eg. CRecordset::Edit() - CRecordset::Update() cycle for mfc developers)
    a row it is locked by the front end application so that no other can commit changes to that row until this user releases the locks by either quitting the application or by moving on to a different record.
    There is a way in oracle functionality to obtain this? In this case other users may read locked record anyway?
    Thank You.

    I've never heard of the Oracle Control Panel, and nothing like that appears on my machine. Is it possible that this is an Oracle forms-type feature? I have a hard time believing that Oracle would or could provide pessimistic locking for arbitrary applications accessing the database.
    The easiest way to implement pessimistic locking is to use the "for update" clause. If I do a "select * from emp for update", every row in the emp table will be locked for writing (Oracle will never block a reader). This assumes that you're not in autocommit mode, since locks will always be released when your transaction ends.
    Justin

  • Memory Leak when I get the SP return refcursor by oracle ODBC driver:

    Oracle server:&#65320;&#65328;&#65293;&#65333;&#65358;&#65353;&#65368;
    Oracle Version: 9.2.0.6.0
    Application Server: windows2003
    Develop tool &#65306; VC++;
    Question:
    when I get the return refcursor by OLEDB.Oracle, there is not any memory leak and work well. But when I change the driver to ODBC “Oralce in OraHome92"
    there will be an 56k memory leak.
    And in the other hand if I call an store precedure without return ref. Both driver /way can work well.
    Can you give me the advice? thanks a lot.
    Code such as:
    _ConnectionPtr m_AdoConnection;
    _CommandPtr pcmd = NULL;
    _RecordsetPtr sp_rs = NULL;
    _bstr_t bstrConstruct = _bstr_t("DSN=test;Uid=test;Pwd=test;PLSQLRSet=1");
    HRESULT hr = CoCreateInstance(__uuidof(Connection),NULL,CLSCTX_INPROC_SERVER,__uuidof(_ConnectionPtr),(LPVOID *)&m_AdoConnection);
    if (FAILED (hr) ) throw hr ;
    m_AdoConnection->PutCursorLocation(adUseClient) ;
    m_AdoConnection->IsolationLevel = adXactSerializable;
    m_AdoConnection->Mode = adModeShareExclusive;
    bstr_t bstrEmpty(L"") ;
    m_AdoConnection->Open (bstrConstruct, bstrEmpty, bstrEmpty, -1) ;
    SAFE_CALL(m_spObjectContext->CreateInstance(__uuidof(Command),__uuidof(_CommandPtr),(LPVOID *)&pcmd));
    if(pcmd == NULL)
    throw CAtlExceptionEx(E_POINTER,"pcmd is NULL");
    pcmd->CommandText = _bstr_t(L"wec_pkg_spl.wec_proc_spl_check");
    pcmd->CommandType = adCmdStoredProc;
    _bstr_t id = _bstr_t("65650000");     
    pcmd->Parameters->Append(pcmd->CreateParameter(_bstr_t(L"id"),DataTypeEnum(adVarChar),adParamInput,2000,_variant_t(id)));          
    pcmd->Parameters->Append(pcmd->CreateParameter(_bstr_t(L"errcode"),DataTypeEnum(adNumeric),adParamOutput,4));
    pcmd->Parameters->Append(pcmd->CreateParameter(_bstr_t(L"errdescription"),DataTypeEnum(adVarChar),adParamOutput,2000));
    pcmd->ActiveConnection = sp_con.m_AdoConnection;
    sp_rs = pcmd->Execute(NULL,NULL,adCmdStoredProc);
    pcmd->Release;          
    sp_rs->Close();     
    if (m_AdoConnection->State == adStateOpen)
    m_AdoConnection->Close();
    wec_pkg_spl.wec_proc_spl_check arguments:
    id          varchar2     in
    flowpaths     ref cursor     out
    errcode          number          out
    errdescription     varchar2     out
    Message was edited by:
    [email protected]

    I'm using the oracle ODBC driver 8.05.10 with MFC and client version 8.0.5. In my experience you can't prevent memory leaks with that or earlier versions of the ODBC driver. Client patchkits or service packs for NT or the Visual Studio doesn't solve the problem.
    The following code will result in a memory leak with the oracle driver. With every expiration of the timer the leak will grow.
    void CTestOdbcOracleDriverDlg::OnTimer(UINT nIDEvent)
    TCHAR errString[255];
    //open the database with class CDatabase
    //use of CRecordset
    TRY {
    //my table name is AL_ALARME_LOG
    pMyRecordset->Open(CRecordset::dynaset,"SELECT * FROM AL_ALARME_LOG",CRecordset::none);
    //do something with the data
    Sleep(0);
    pMyRecordset->Close();
    CATCH_ALL(error) {
    error->GetErrorMessage(errString,255);
    DELETE_EXCEPTION(error);
    END_CATCH_ALL
    CDialog::OnTimer(nIDEvent);
    The same code with the Microsoft ODBC driver
    doesn't cause memory leaks.
    Andreas ([email protected])

  • How to obtain aggregate results using ODBC?

    How do I obtain results of an aggreate functions like SUM etc? I have an MFC application that uses CRecordset. Following is the code snip:
    CDatabase db1;
    o1 db; // class that is a sub class of CRecordset and makes a connection to the Oracle
    // database
    try
    BOOL bUseCursorLib = FALSE;
    db1.Open(_T( "globaldb" ), FALSE, FALSE, _T( "ODBC;UID=scott;PWD=tiger" ),FALSE);
    catch(CDBException* e)
    TRACE0(e->m_strError + "\n");
    AfxMessageBox("Error... "+e->m_strError);          
    e->Delete();
    if( db1.IsOpen() )
    db1.Close();     
    CString strCmd = "select sum(ordernumber) from orders";
    try
    db1.ExecuteSQL( strCmd );
    catch(CDBException *e)
    AfxMessageBox("Error here: "+e->m_strError);
    CString t;
    t.Format("Sum=%ld",db.m_sum_ORDERNUMBER);
    AfxMessageBox(t);
    I always get zero displayed as the sum. I am going wrong somewhere for sure. I am not able to figure out.

    This ought to work. Can you verify that you have the latest ODBC driver and that you have the proper version of the MDAC installed?
    Justin

Maybe you are looking for