Re: Visual C++ 6 and ODBC



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
>
>
>
.



Relevant Pages

  • Re: How to load data in ListBox using one command from ADODB Recor
    ... Simply use an DSN-less connection string as the ODBC Connection String. ... >> Is there something unique about how you use the ADODB recordset? ... >>> I am using ADODB recordset and has SQL server database. ...
    (microsoft.public.access.gettingstarted)
  • Re: ODBC connection strings - "ODBC;" prefix?
    ... As you can see, if there is "ODBC;" in the connection string, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vc.database)
  • Re: ODBC string in ADO.NET
    ... You are using an Ole DB connection string with the ... ODBC provider classes. ... The .Net Framework Data Provider for ELEDB does not ... ..Net Framework Data Provider for ODBC. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ODBC connection strings - "ODBC;" prefix?
    ... MFC is adding the "ODBC;" in the call I referenced in my prior reply. ... As you can see, if there is "ODBC;" in the connection string, ... Microsoft Online Community Support ...
    (microsoft.public.vc.database)
  • Re: ADO, ODBC, Service process
    ... I downloaded Jet engin 4.0 and used the connection string as you showed. ... (LocalSystem here who has no permission on the file server). ... >> ODBC dBase]'' is not a valid path. ...
    (borland.public.delphi.database.ado)

Loading