Click here to Skip to main content
15,896,414 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MSIL
Hi all;
I am working my way through the documentation for a walkthrough (C++):
"Walkthrough: Creating a Rich Client Application with MFC"
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_vswalk/html/ff258cfd-ccf1-4986-815e-e586809b9f51.htm

At one point, the walkthrough specifies that I should copy-paste
a code snippet into the OnInitialUpdate method of the CMyProjectView class.
The snippet implements the db_command attribute:
============================================================
<pre>   HRESULT hr = S_OK;
   TCHAR szAuthor[80];
   CMyProjectSet &dbset = GetDocument()->m_MyProjectSet;
   [db_command(name="cmd", source_name="dbset", hresult=hr)
   {
      SELECT au_lname
      ([bindto]szAuthor)
      FROM AUTHORS
   }];
   while(cmd.MoveNext() == S_OK)
      m_DataList.InsertString(-1, szAuthor);

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

On build, the compiler has no idea as to what that stuff is, and
reacts accordingly - with several compilation diagnostics:
============================================================
Error
MSIL
1   error C2143: syntax error : missing ']' before '{'  c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 99  Authors-02
Error   2   error C2440: 'initializing' : cannot convert from 'HRESULT' to 'const char *'   c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 98  Authors-02
Error   3   error C2143: syntax error : missing ';' before '{'  c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 99  Authors-02
Error   4   error C2065: 'SELECT' : undeclared identifier   c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 101 Authors-02
Error   5   error C2146: syntax error : missing ';' before identifier 'au_lname'    c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 101 Authors-02
Error   6   error C2143: syntax error : missing ')' before '['  c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 101 Authors-02
Error   7   error C2065: 'bindto' : undeclared identifier   c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 101 Authors-02
Error   8   error C2146: syntax error : missing ';' before identifier 'szAuthor'    c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 101 Authors-02
Error   9   error C3861: 'au_lname': identifier not found   c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 101 Authors-02
Error   10  error C2059: syntax error : ')' c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 101 Authors-02
Error   11  error C2146: syntax error : missing ';' before identifier 'FROM'    c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 102 Authors-02
Error   12  error C2065: 'FROM' : undeclared identifier c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 103 Authors-02
Error   13  error C2146: syntax error : missing ';' before identifier 'AUTHORS' c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 103 Authors-02
Error   14  error C2065: 'AUTHORS' : undeclared identifier  c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 103 Authors-02
Error   15  error C2143: syntax error : missing ';' before '}'  c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 103 Authors-02
Error   16  error C2143: syntax error : missing ';' before ']'  c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 103 Authors-02
Error   17  error C2065: 'cmd' : undeclared identifier  c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 105 Authors-02
Error   18  error C2228: left of '.MoveNext' must have class/struct/union   c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 105 Authors-02
Error   19  fatal error C1903: unable to recover from previous error(s); stopping compilation   c:\projects\aaaplayground\walkthroughs\authors-02\authors-02\authors-02view.cpp 105 Authors-02

============================================================
How do I get the compiler to recognise the attribute?
What am I missing here?
I'm using Visual Studio 2008.
Thanks!!!
Posted

Looks like my answer was lost. I think you need a space between [ and db_command. You could also download the samples on MSDN and try to see if they work, and how they differ from your code.
 
Share this answer
 
I've gotten the answer: The code within the docs is no good.
The online docs are more accurate.

Thanks for reading!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900