| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2726 人关注过本帖
标题:用ADO连接SQL数据库的问题! 急!!!!!!!!!!
只看楼主 加入收藏
xjlsgcjdtc
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-9-4
收藏
 问题点数:0 回复次数:1 
用ADO连接SQL数据库的问题! 急!!!!!!!!!!
我想用ADO连接SQL Server数据库

但是编译的时候老报错   智能指针未定义

错误如下:

d:\program files\microsoft visual studio\myprojects\图书管理系统 1\1.h(25) : error C2146: syntax error : missing ';' before identifier 'm_pConnection'
d:\program files\microsoft visual studio\myprojects\图书管理系统 1\1.h(25) : error C2501: '_ConnectionPtr' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\myprojects\图书管理系统 1\1.h(25) : error C2501: 'm_pConnection' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\myprojects\图书管理系统 1\1dlg.h(19) : error C2146: syntax error : missing ';' before identifier 'm_pRecordset'
d:\program files\microsoft visual studio\myprojects\图书管理系统 1\1dlg.h(19) : error C2501: '_RecordsetPtr' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\myprojects\图书管理系统 1\1dlg.h(19) : error C2501: 'm_pRecordset' : missing storage-class or type specifiers
D:\Program Files\Microsoft Visual Studio\MyProjects\图书管理系统 1\1.cpp(67) : error C2065: 'm_pConnection' : undeclared identifier
D:\Program Files\Microsoft Visual Studio\MyProjects\图书管理系统 1\1.cpp(67) : error C2228: left of '.CreateInstance' must have class/struct/union type
D:\Program Files\Microsoft Visual Studio\MyProjects\图书管理系统 1\1.cpp(70) : error C2227: left of '->Open' must point to class/struct/union

但是我在 stdafx.h 中已经加入了
#import "C:\program files\common files\system\ado\msado15.dll"  no_namespace rename("EOF","adoEOF") rename("BOF","adoBOF")

在应用程序类中加入了 (我在最初注册SQL 服务器组的时候 用的是"windows身份验证",而不是"SQL Server验证",所以没有用户名和密码)

 if(! AfxOleInit())
    {
        AfxMessageBox("初始化失败!");
            return FALSE;
    }
 AfxEnableControlContainer();
 //初始化com对象
 CoInitialize(NULL);
 try
 {
  //初始化数据连接对象
  m_pConnection.CreateInstance("ADODB.Connection");
  m_pConnection->Open("driver={SQL Server};Server=2AD32E4C8D614AD;DATABASE=libruary;UID='';PWD=''","","",adModeUnknown);
 }
 catch (_com_error* e)
 {
  AfxMessageBox(e.Description());
 }

如果我在主对话框类中加入
#import "C:\program files\common files\system\ado\msado15.dll"  no_namespace rename("EOF","adoEOF") rename("BOF","adoBOF")
编译器就不会报错,但是连不上数据库!
紧急求救!
搜索更多相关主题的帖子: SQL ADO 数据库 program 
2007-12-02 15:40
xe569886048
Rank: 2
等 级:论坛游民
威 望:1
帖 子:59
专家分:28
注 册:2009-10-9
收藏
得分:0 
主对话框  包含ADO类了么?
2010-12-10 22:17
快速回复:用ADO连接SQL数据库的问题! 急!!!!!!!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018012 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved