RE: Visual C++ 6 and ODBC



Hi there,

It is the same code it seems from VC++6 and .NET e.g.

where 'connect' is the connection string i.e. database name, username,
passowrd etc..

CDatabase db;
try
{
bSuccess = db.Open(connect);

if(!bSuccess)
{
AfxMessageBox( "DB Connection failed!" );
return;
}
}

catch(CDBException* pEx)
{
AfxMessageBox(pEx->m_strError);
pEx->Delete();
AfxMessageBox( "DB Connection failed!" );
return;
}

try
{
// Display Success
AfxMessageBox( "Connected to Database" );
}
catch (CDBException *pEx)
{
// The only exception we should get is an illegal SQL statement
AfxMessageBox(pEx->m_strError);
pEx->Delete();
AfxMessageBox("SQL Error!");
}
// Close Database
db.Close();

"David++" wrote:

> Hi folks,
>
> I'm writing to ask if anyione has any information on how to get an ODBC
> connection up and running under Visual C++ 6. I've been using Visual C++.NET
> and have managed to get a database connection up and running using the MFC
> ODBC Consumer in the Class Wizard. However, I think I might have to code the
> connection by hand in Visual C++ 6? I'm not sure of the possibilites of VC++6
> as I've been using .NET up till now and had to downgrade for thei particular
> project. Is it possible to use the same include files in VC++6 as used in
> .NET in order to use the Database connection classes and functions?
>
> Any tips or advice on how to get started are very much appreciated.
>
> Sincerely,
>
> David Ross
.



Relevant Pages

  • Re: ADO Connection Timeout
    ... so what happens when a connection failure forces one station to revert ... to a local database? ... Further, you *will* have contention issues, Jet does not support record ... to the central server, but you are willing to live with periods where it ...
    (microsoft.public.data.ado)
  • Re: ADO Connection Timeout
    ... When the first test is run, the results are stored in the central database. ... to the central server, but you are willing to live with periods where it ... i.e. a local database or even a text file. ... to function until the connection can be restored to the server. ...
    (microsoft.public.data.ado)
  • Re: ADO Connection Timeout
    ... to the central server, but you are willing to live with periods where it ... i.e. a local database or even a text file. ... to function until the connection can be restored to the server. ...
    (microsoft.public.data.ado)
  • Re: ADO Connection Timeout
    ... much rather write stored procedures and use server side cursors. ... local database, it is vital that I get the information to a central server. ... Once the connection is restored, ...
    (microsoft.public.data.ado)
  • Re: ESQL/C documentation nightmare
    ... documentation about explicit and implicit connections. ... CONNECTION connection statements for new applications of Version 6.0 ... the SQL database statements (such as ...
    (comp.databases.informix)

Loading