- UID
- 341
- 积分
- 1337
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-11
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
在VC的环境里编译通过,但在ARX的某个命令的函数里添加就出现编译错误 说是有
g:\ddcad\草稿\classtest\debug\msado15.tlh(171) : error C2011: 'LockTypeEnum' : 'enum' type redefinition
g:\ddcad\草稿\classtest\debug\msado15.tlh(214) : error C2011: 'DataTypeEnum' : 'enum' type redefinition
g:\ddcad\草稿\classtest\debug\msado15.tlh(258) : error C2011: 'FieldAttributeEnum' : 'enum' type redefinition
g:\ddcad\草稿\classtest\debug\msado15.tlh(279) : error C2011: 'EditModeEnum' : 'enum' type redefinition
g:\ddcad\草稿\classtest\debug\msado15.tlh(287) : error C2011: 'RecordStatusEnum' : 'enum' type redefinition
g:\ddcad\草稿\classtest\debug\msado15.tlh(530) : error C2011: 'ParameterDirectionEnum' : 'enum' type redefinition
g:\ddcad\草稿\classtest\debug\msado15.tlh(2664) : error C2059: syntax error : 'constant'
代码如下:
/////////////////////////////////////////////////////////////////////////#import "D:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
///////////////////////////////////////////
- //测试数据库连接
- AfxOleInit();
-
- char *IDKEY =new char[256];
- strcpy(IDKEY ,"IDKEY");
- _RecordsetPtr pRecordset;
- char* idKey ;
- char * curTable;
- _variant_t recordsAffected;
- _ConnectionPtr pConnection=NULL;
- char * tmSysPath=NULL;
- //路径
- if (tmSysPath==NULL) {
- tmSysPath=new char[1024];
- strcpy(tmSysPath ,"G:\\Ddcad\\Ddsz2004\\userinfo.mdb");
- }
-
- if (pConnection==NULL)
- {
-
- pConnection.CreateInstance("ADODB.Connection");
-
- try
- {
- pConnection->ConnectionTimeout = 8;
- char *datsource=new char[1024];
-
- strcpy(datsource,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="); //将来可以考虑连接不同的数据库
- strcat(datsource, tmSysPath );
-
-
- //AfxMessageBox(datsource);
- pConnection->Open(datsource ,"","",adModeUnknown);
- }
- catch(_com_error e)///捕捉异常
- {
- AfxMessageBox(" 数据库连接失败!");
- }
- }
-
- ///初始化必要变量
- curTable=new char[256]="users"; //真的可以这样初始化一个字符串!!
- idKey="ID001";
-
- AfxMessageBox(" !");
- char * dat=new char (256);
- strcpy(dat , "xxxxxx");
- char * dataname=new char (256);
- strcpy(dataname , "tablx");
- char* sqlcmd=new char(256);
- sprintf(sqlcmd ,"%s%s%s%s%s%s%s%s%s","SELECT ",dataname, \
- " from " , curTable ," where ",IDKEY ,"='",idKey ,"'" );
-
- try
- {
-
- pConnection->Execute( sqlcmd ,&recordsAffected,adCmdText);
-
- }
- catch ( ... )
- {
- AfxMessageBox("查找数据失败"); //调试使用显示
-
- }
- //下面将搜索到底数据取出来。执行SQL统计命令得到包含记录条数的记录集
-
- pRecordset =pConnection->Execute(sqlcmd,&recordsAffected,adCmdText);
- _variant_t vIndex = (long)0;
- _variant_t vCount = pRecordset->GetCollect(vIndex);///取得第一个字段的值放入vCount变量
- pRecordset->Close();///关闭记录集
- if (V_VT(&vCount) ==VT_NULL) // 判断vCount获取合适的值??
- {
- delete sqlcmd;
- }
- else
- {
-
- _bstr_t bstr(vCount) ;
- strcpy(dat,(char *)bstr);
- AfxMessageBox(dat); //可以获取自己需要的值!!
- pConnection->Close();
- delete sqlcmd;
- }
复制代码 |
|