From: kean on
Perhaps I'm naive but I had a thought of being able to port my vb database
connection code to vc - mfc.

My aim was to use something like an SqlConnection and a dbReader. But it is
not working other than adding a /clr "gear" in solutions property page, for
building the application. I can't remember having such problems with the old
vs 6 environment and its old recordset syntax.

So my question is what are my db connection options if I want to use
unmanaged/native compilation on my mfc applications?

//Kent
From: David Ching on
"kean" <kean(a)discussions.microsoft.com> wrote in message
news:CB14D7FF-1783-4D95-89B5-76C3D31F97CF(a)microsoft.com...
> So my question is what are my db connection options if I want to use
> unmanaged/native compilation on my mfc applications?
>

ADO is the native way to do it. I found a MFC wrapper for it:
http://www.codeproject.com/KB/database/adoclasses.aspx but haven't tried it.

-- David



From: Goran on
+1 for ADO. IMO, best balance between functionality and ease of use in
native code under windows. Allows you to access +/- any SQL DB, and
some more data sources, too (e.g Excel, "Text" databases, not that one
would want to use ADO for that).

Goran.
From: kean on
Ok, but I can see that CADO… objects still use the #import
"C:\....msado15.dll" in the header files. That is the same file a used in
vs6! Does that mean that code like below are still valid? And the way to
program databases unmanaged, or have I missed something?

SelPerson rsPerson;
_RecordsetPtr pRs;
IADORecordBinding* piAdoRecordBinding;

pRs.CreateInstance(__uuidof(Recordset));


pRs->Open("pSelPerson " + (_bstr_t)m_strPersnrSok, Globalt.strCnn,
adOpenForwardOnly, adLockReadOnly, adCmdText);
if(FAILED(pRs->QueryInterface(__uuidof(IADORecordBinding), (LPVOID
*)&piAdoRecordBinding)))
_com_issue_error(E_NOINTERFACE);


piAdoRecordBinding->BindToRecordset(&rsPerson);