C ++编译器不了解db_command属性 [英] C++ Compiler Doesn't Understand the db_command Attribute
问题描述
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
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
================================================== ==========
如何让编译器识别该属性?
我在这里想念什么?
我正在使用Visual Studio2008.
谢谢!!!
============================================================
How do I get the compiler to recognise the attribute?
What am I missing here?
I''m using Visual Studio 2008.
Thanks!!!
推荐答案
好像我的答案丢失了.我认为您需要[和db_command之间的空间.您还可以在MSDN上下载示例,然后尝试查看它们是否有效以及它们与您的代码有何不同.
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.
我已经得到了答案:文档中的代码不是好.
在线文档更加准确.
感谢您的阅读!!!
I''ve gotten the answer: The code within the docs is no good.
The online docs are more accurate.
Thanks for reading!!!
这篇关于C ++编译器不了解db_command属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!