Re: Visual C++ 6 and ODBC
- From: "David++" <David@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 8 Jun 2005 03:35:03 -0700
Hi Joe,
My connection string works like this -
CString str = "ODBC;DSN=" + name + ";UID=" + user + ";PWD=" + pass + ";" ;
char connect [250] = "";
sprintf(connect, str);
where 'name' is the name of the database, 'user' is the User ID and 'pass'
is Password
Seems to work for me. Not sure if this is the best way though.
Cheers
"Joe Butler" wrote:
> What's your connection string look like. Anything like this?
>
> "Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\\mydatabase.mdb"
>
> I would have thought it doubful that you could use teh headers from .Net,
> but I don't use .Net, so don't really know.
>
> But, using either MFC or SDK in VC6 you can certainly connect to Jet
> (Access) databases and others via ODBC drivers that are installed on the
> client and run certain SQL statements against them depending on the driver.
>
>
> "David++" <David@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:2B67D171-CB4A-4E04-B629-B92493EFED0A@xxxxxxxxxxxxxxxx
> > 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
>
>
>
.
- References:
- Visual C++ 6 and ODBC
- From: David++
- RE: Visual C++ 6 and ODBC
- From: David++
- Re: Visual C++ 6 and ODBC
- From: Joe Butler
- Visual C++ 6 and ODBC
- Prev by Date: RE: crdb_p2bbtr.dll
- Next by Date: RE: VB.NET 2005 Beta 2 ODBC error: key should not be empty paramet
- Previous by thread: Re: Visual C++ 6 and ODBC
- Next by thread: odbc manual
- Index(es):
Relevant Pages
|
Loading