代码如下:
#import "c:\program files\common files\system\ado\msadox.dll"
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
ADOX::_CatalogPtr pCatalog(__uuidof(ADOX::Catalog));
_bstr_t str="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+m_strDBName;
CFileFind fd;
if(!fd.FindFile(m_strDBName))
{
try
{
pCatalog->Create(str); //创建数据库
}
catch(_com_error *e)
{
//错误处理
AfxMessageBox("数据库创建失败!");
return FALSE;
}
}
错误如下:
--------------------Configuration: XY2_PK - Win32 Debug--------------------
Compiling...
ProduceData.cpp
error C2653: 'ADOX' : is not a class or namespace name
error C2065: '_CatalogPtr' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'pCatalog'
error C2065: 'pCatalog' : undeclared identifier
error C2653: 'ADOX' : is not a class or namespace name
error C2065: 'Catalog' : undeclared identifier
error C2227: left of '->Create' must point to class/struct/union
Error executing cl.exe.- 7 error(s), 0 warning(s)我想主要是error C2653: 'ADOX' : is not a class or namespace name
这里有问题,为什么ADOX会有问题,请帮忙解决下.
#import "c:\program files\common files\system\ado\msadox.dll"
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
ADOX::_CatalogPtr pCatalog(__uuidof(ADOX::Catalog));
_bstr_t str="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+m_strDBName;
CFileFind fd;
if(!fd.FindFile(m_strDBName))
{
try
{
pCatalog->Create(str); //创建数据库
}
catch(_com_error *e)
{
//错误处理
AfxMessageBox("数据库创建失败!");
return FALSE;
}
}
错误如下:
--------------------Configuration: XY2_PK - Win32 Debug--------------------
Compiling...
ProduceData.cpp
error C2653: 'ADOX' : is not a class or namespace name
error C2065: '_CatalogPtr' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'pCatalog'
error C2065: 'pCatalog' : undeclared identifier
error C2653: 'ADOX' : is not a class or namespace name
error C2065: 'Catalog' : undeclared identifier
error C2227: left of '->Create' must point to class/struct/union
Error executing cl.exe.- 7 error(s), 0 warning(s)我想主要是error C2653: 'ADOX' : is not a class or namespace name
这里有问题,为什么ADOX会有问题,请帮忙解决下.
这个问题我想了一天没解决,突然找到办法了,右击ADOX,GO TO Definition of ADOX
于是出现下面Compiling...
StdAfx.cpp
d:debug\msadox.tlh(1203) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
d:debug\msado15.tlh(407) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
Linking...
Creating browse info file...XY2_PK.exe - 0 error(s), 2 warning(s)然后就好了.不知道为什么.我也看了很多人用这个ADOX会出问题,不知道是不是这个问题.