Need help with database connection from Win32 Application

Need help with database connection from Win32 Application

Post by Deepa Jaco » Thu, 23 May 2002 23:51:42



Hi All,

Hope this is the proper group to ask this.
I need to make database connection from a Win32 Application.
Which will be preferable, ODBC or ADO?
If possible, can u pls give me an example.

Thanks,
Deepa

 
 
 

Need help with database connection from Win32 Application

Post by Roy Fin » Fri, 24 May 2002 00:19:28


Deepa,
the preferable technology is dependent on a lot of factors - the programmers
level of proficiency with a certain technology, target platform, etc, etc...

If all things are equal, then the preference may be towards ADO, with ODBC a
close second for now and DAO slipping further behind that.

If you want examples, see the MSDN Help files ofr ADO Connection object.

Here is a quick sample.  I hope it helps a bit.

best regards,
roy fine

wchar_t *cnxtstr = L"Provider=xxxx;Data Source=yyy;User
ID=ppp;Password=qqq;";
#import "C:\program files\common files\system\ado\msado.tlb" no_namspace
/* ************************* */
int main(...){
::CoInitialize(NULL);
_ConnectionPtr cnxion;
cnxion.CreateInstance(__uuidof(Connection));
cnxion.CursorLocation=adUseServer;
cnxion->Open(cnxtstr,L"",L"",adConnectUnspecified);
...
...
...
cnxion->Close();
cnxion.Release();
::CoUninitialize();

Quote:}

/* ************** end of code hack ************* */


Quote:> Hi All,

> Hope this is the proper group to ask this.
> I need to make database connection from a Win32 Application.
> Which will be preferable, ODBC or ADO?
> If possible, can u pls give me an example.

> Thanks,
> Deepa


 
 
 

Need help with database connection from Win32 Application

Post by Deepa Jaco » Fri, 24 May 2002 00:44:55


Thanks for u'r help, i'll try that
-Deepa


> Deepa,
> the preferable technology is dependent on a lot of factors - the
programmers
> level of proficiency with a certain technology, target platform, etc,
etc...

> If all things are equal, then the preference may be towards ADO, with ODBC
a
> close second for now and DAO slipping further behind that.

> If you want examples, see the MSDN Help files ofr ADO Connection object.

> Here is a quick sample.  I hope it helps a bit.

> best regards,
> roy fine

> wchar_t *cnxtstr = L"Provider=xxxx;Data Source=yyy;User
> ID=ppp;Password=qqq;";
> #import "C:\program files\common files\system\ado\msado.tlb" no_namspace
> /* ************************* */
> int main(...){
> ::CoInitialize(NULL);
> _ConnectionPtr cnxion;
> cnxion.CreateInstance(__uuidof(Connection));
> cnxion.CursorLocation=adUseServer;
> cnxion->Open(cnxtstr,L"",L"",adConnectUnspecified);
> ...
> ...
> ...
> cnxion->Close();
> cnxion.Release();
> ::CoUninitialize();
> }
> /* ************** end of code hack ************* */



> > Hi All,

> > Hope this is the proper group to ask this.
> > I need to make database connection from a Win32 Application.
> > Which will be preferable, ODBC or ADO?
> > If possible, can u pls give me an example.

> > Thanks,
> > Deepa