PRB: "Invalid argument" with dbAttachedTable or dbAttachedODBC (141351)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Learning Edition 4.0
    • Microsoft Visual C++, 32-bit Professional Edition 4.0

This article was previously published under Q141351

SYMPTOMS

When trying to pass dbAttachedTable or dbAttachedODBC as arguments to the CDaoTableDef::Create() function or the CDaoTableDef::SetAttributes() function, you will receive this DAO error:
Error Code = 3001
....
Description = Invalid argument.

CAUSE

The Visual C++ documentation is incorrect. The values dbAttachedTable and dbAttachedODBC cannot be passed as arguments. These attributes are read- only attributes that are set internally by DAO based on the information provided in the connect string of the table.

RESOLUTION

Do not try to set these attributes. DAO will set the attributes based on what is contained in the connect string for the table. For example, look at this code:
   td.Create(_T("Table1"),0,_T("Table1"),
      _T("FoxPro 2.6;DATABASE=d:\\mydatabase\\"));
				
DAO will set the dbAttachedTable attribute flag for that table. A call to CDaoTableDef::GetAttributes() will show the flag has been set.

STATUS

This behavior is by design.

Modification Type:MajorLast Reviewed:11/18/2003
Keywords:kbDatabase kbprb kbProgramming KB141351