Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DAO3.6 and VS2005

0 views
Skip to first unread message

Granta Guy

unread,
Sep 3, 2007, 1:12:09 PM9/3/07
to
I'm attempting to port a VC 6 MFC Application that uses DAO3.6 to VS2005. To
do this, I believe I need to recompile the DDAO library, which, after some
code changes, I have managed. But when I start my application, it loads
DAO3.5 and MSJET35.dll, not 3.6 and MSJET40.... and I can't open my database.

I have pulled the DAO source code from the support folder of VC6 SP6, as
suggested in the Service Pack Readme.

Any suggestions on how to proceed? I appreciate that DAO is just not used
any longer, but this would breath a bit of life back into an old product, so
I am keen to get it working.

Thanks

Granta Guy

Charles Wang[MSFT]

unread,
Sep 4, 2007, 2:03:27 AM9/4/07
to
Hi Granta,
Thanks for using Microsoft MSDN Managed Newsgroup.

I understand that your application loaded old version DLLs DAO350.DLL and
MSJET35.DLL but not DAO360.DLL and MSJET40.DLL after your application was
ported from VC6.0 to VS2005.
If I have misunderstood, please let me know.

Could you please let me know your Windows OS version and Office version?
I am not sure if you had installed the latest service pack for Microsoft
Jet4.0 database engine, but you may refer to this article first:
How to obtain the latest service pack for the Microsoft Jet 4.0 Database
Engine
http://support.microsoft.com/kb/239114/en-us

I wrote a simple project with CDaoDatabase and CDaoRecordset in Visual
Studio 2005 and it worked fine with loading dao360.dll and msjet40.dll at
runtime in my Windows XP SP2 machine with Microsoft Office 2003 installed.
My sample code is as following:
#include "afxdao.h"
..
void CMyDaoView::GetSales(int nId,CList<CString,CString&>& lstSales)
{
CString strId;
COleVariant varValue;
m_db.Open(_T("F:\\Test\\DB\\Access\\Sales.mdb"),FALSE,FALSE,_T(""));

strId.Format(_T("SELECT CustName FROM Customer WHERE CustId=%d"),nId);
m_rs.m_pDatabase = &m_db;
m_rs.Open(dbOpenDynaset,strId.GetBuffer(100),dbForwardOnly);
while(!m_rs.IsEOF())
{
m_rs.GetFieldValue(_T("CustName"),varValue);
CString strVal(varValue.bstrVal);
INT_PTR pCount = lstSales.GetCount();
if(pCount == 0)
lstSales.AddHead(strVal);
else
lstSales.InsertAfter(lstSales.GetHeadPosition(),strVal);
m_rs.MoveNext();
}

m_rs.Close();
m_db.Close();
}

Then I ran the MDI application and used Process Monitor to monitor the
process and I found that C:\Program Files\Common Files\Microsoft
Shared\DAO\dao360.dll and C:\WINDOWS\system32\msjet40.dll were loaded. I
recommend that you check if the two DLLs are located in the right path in
your computer and try manually running "regsvr32 <dao360.dll's path>" to
see if it helps.

If the above suggestions do not help, I recommend that you mail me
(changliw_at_microsoft_dot_com) a small sample project so that I can
reproduce your issue at my side.

If you have any other questions or concerns, please feel free to let me
know. Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================


Granta Guy

unread,
Sep 4, 2007, 5:52:07 AM9/4/07
to
Thanks for the reply, however, I think that you've assumed I'm using DAO
through MFC. Actually, I'm using the DAO SDK (what was originally DAO 3.5
SDK). This uses classes like CdbDatabase and CdbRecordset, rather than the
MFC equivalents (CDaoDatabase CDaoRecordset..)

The DAO SDK was shipped, I think, with vanilla VC 6 as a separate install.
The original version supported jet3.5, but there was an update to DAO3.6 that
was shipped as extra files in the support folder (according to the readme of
SP5 or SP6 for VC). It is this dll (DDAO36.dll) that I need to rebuild, since
it uses MFC string classes.

I am up-to-date with DAO and Office - and when I open the original project
in VC6, it loads up the correct DAO DLL's.

The problem, I suspect, is that the DAO 3.6 SDK was a bit shambolic - a
bunch of files shipped in the support folder of VC 6 Service Pack.
Unfortunately, it was shipped with a whole bunch of other support files and
lumped in together, so picking out the pieces is a bit tricky.

Has this cleared the picture a bit? I will also look at the MFC dao classes
to see if there is a close enough mapping to perhaps switch to them instead,
which might be a possibility.

Thanks!

Granta Guy

Charles Wang[MSFT]

unread,
Sep 5, 2007, 4:37:58 AM9/5/07
to
Hi Granta,
Thanks for your feedback.
DAO SDK was really a very old database access technique. I even could not
find it in MSDN documents.
From my research, DAO SDK must be installed from VC6.0 or earlier version
(VC4.0) Setup CD. I checked my VC6.0 setup CD and found the DAOSDK folder.
Then I installed it and I found that the SDK used Jet3.5 libraries. Then I
tried to write a program, however if I included the header file dbdao.h, it
required me to include the library DDAO35D.LIB which was for DAO350.DLL. I
tried to search my computer and did not find a .lib file for DAO360.DLL,
and then I changed a method by explicitly importing the DAO360.DLL and it
worked. I am not sure how your original program worked, however I think
that the following code snippets may give you some hints for resolving your
issue:
----------------------------------------------------------------------------
--------------------------
#import "C:\Program Files\Common Files\Microsoft Shared\DAO\DAO360.DLL" \
rename("EOF","TEof") rename("BOF","TBof")

.....
TCHAR stmt[1024];

HRESULT hr = CoInitialize(NULL);
if(FAILED(hr))
return;

DAO::_DBEnginePtr pDbEngine(__uuidof(DAO::DBEngine));
DAO::RecordsetPtr pRs;
DAO::FieldsPtr pFields;
DAO::DatabasePtr pDb;
pDb = pDbEngine->OpenDatabase(_T("F:\\Test\\DB\\Access\\Sales.mdb"));
pRs = pDb->OpenRecordset(_T("Customer"),DAO::dbOpenTable);
if(pRs->RecordCount!=0)
{
int n = 0;
this->m_lscResult.InsertColumn(0,_T("Customer Id"),LVCFMT_LEFT,80);
this->m_lscResult.InsertColumn(1,_T("Customer Name"),LVCFMT_LEFT,100);
this->m_lscResult.InsertColumn(2,_T("Description"),LVCFMT_LEFT,300);

pRs->MoveFirst();
while(!pRs->TEof)
{
pFields = pRs->GetFields();
int nId = (int)(pFields->GetItem(_T("CustId"))->GetValue());
CString strId;
strId.Format(_T("%d"),nId);
CString strName = pFields->GetItem(_T("CustName"))->GetValue();
CString strDesc = pFields->GetItem(_T("CustDesc"))->GetValue();
this->m_lscResult.InsertItem(n,strId.GetBuffer(0));
this->m_lscResult.SetItemText(n,1,strName.GetBuffer(0));
this->m_lscResult.SetItemText(n,2,strDesc.GetBuffer(0));
++n;
pRs->MoveNext();
}
}

pRs->Close();
pDb->Close();

CoUninitialize();
----------------------------------------------------------------------------
-------------------------------------------

If you have any other questions or concerns, please feel free to let me

know. Have a nice day!

Charles Wang[MSFT]

unread,
Sep 7, 2007, 3:49:25 AM9/7/07
to
Hi Granta,
I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support

======================================================

Granta Guy

unread,
Sep 12, 2007, 12:44:05 PM9/12/07
to
Well, I've been looking at this issue, and I've decided to use your #import
method with the DAO SDK to try and get it to build. I changed the import to
use raw interfaces, since that is what DAO uses. Hopefully if I can build the
DAO SDK, I won't need to rewrite any of my own code.

But one issue has arisen. DAO SDK had a method called GetRowsEx on a
recordset. There is a method called SetGetRowsExInt that is key:

prs->QueryInterface(IID_ICDAORecordset, (void **)&pGetRows);

I don't yet know what this CDAORecordset is; can you shed any light on that
one?

Otherwise, I think it will be successful, so thanks for your help.

GrantaGuy

Charles Wang[MSFT]

unread,
Sep 14, 2007, 5:47:55 AM9/14/07
to
Hi Granta,
IID_ICDAORecordset should be the GUID of the interface ICDAORecordset which
I think is the interface of Recordset. For example, we can use it as
following:
ICDAORecordset* pCDAORecordset = 0;
pDaoRS->QueryInterface(IID_ICDAORecordset, (void**)&pCDAORecordset);
hr = pCDAORecordset->GetRows(0, 1, daoBindings, sizeof(ColumnData),
&fetchRows);

As you can see, it has the same behavior as Recordset. However I could not
find any documents explaining this. I will try to consult the product team
on this issue to see if they could give me some information. Since this SDK
is very old, I am not sure if I could get a response now, however if there
is any response I will let you know.

If you have any questions or concerns, please feel free to let me know.
Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================

Charles Wang[MSFT]

unread,
Sep 21, 2007, 6:06:41 AM9/21/07
to
Hi Granta,
Sorry for letting you wait a long time. Now I get the response from the Dev
team and the ICDAORecordset interface is declared in this header file by
default:
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\daogetrw.h

From this header file, you can see the following declarations:
#undef INTERFACE
#define INTERFACE ICDAORecordset
DECLARE_INTERFACE_(ICDAORecordset, IDispatch)
{
STDMETHOD(GetRows) (THIS_ LONG cRowsToSkip, LONG cCol,
LPDAOCOLUMNBINDING prgBndCol, ULONG cbRowLen, LPDAOFETCHROWS pFetchRows)
PURE;
STDMETHOD(SetNotify) (THIS_ REFIID riid, BOOL fNotify);
STDMETHOD(GetNotify) (THIS_ REFIID riid, BOOL *fNotify);
STDMETHOD(OnBeforeNotify) (THIS_ REFIID riid, DWORD cat, DWORD rsn,
VARIANT v1, VARIANT v2);
STDMETHOD(OnAfterNotify) (THIS_ REFIID riid, DWORD cat, DWORD rsn, VARIANT
v1, VARIANT v2, HRESULT hr);
STDMETHOD(PutLock) (THIS_ BOOL f);
STDMETHOD(GetLock) (THIS_ BOOL *f);
STDMETHOD(AddGetRowsErr) (THIS_ HRESULT hr) PURE;
};

So now we can conclude that the CDAORecordset in DAO SDK is a seperate
class with exposing ICDAORecordset interface which contains the above
interface functions.

Hope this helps. If you have any questions or concerns, please feel free to
let me know. Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================

Granta Guy

unread,
Sep 25, 2007, 6:14:00 AM9/25/07
to
Thanks for your help. I now have a working DAO library, using the method you
suggested, and it seems to be OK. Thanks again.

Charles Wang[MSFT]

unread,
Sep 26, 2007, 5:57:55 AM9/26/07
to
Hi Granta,
Thanks for your feedback and let me know that you had a working DAO library
now. Congratulations!

If you have any questions or concerns in future, please feel free to post
here. Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support

======================================================

0 new messages