请问如何连接sqlserver2000数据库,用adoconnection? 请问如何连接sqlserver2000数据库,用adoconnection?最好有源代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //定义_RecordsetPtr m_Recordset;_CommandPtr m_Commandptr;_ConnectionPtr m_pConnection;//连接HRESULT hr; hr=m_pConnection.CreateInstance("ADODB.Connection"); if(!SUCCEEDED(hr)) { AfxMessageBox("数据库初始化出错!"); return false; }CString m_username;//用户名 CString m_password;//密码 CString m_dbserver; //数据服务器名 CString m_dbtable;//数据库名CString strConnection = "Provider=SQLOLEDB.1;Data Source=" + m_dbserver + ";Initial Catalog=" + m_dbtable + ";User ID=" + m_username + "; PWD=" + m_password; try { theApp.m_pConnection->Open((_bstr_t)strConnection,"","",-1); } catch(_com_error e) { CCommon common; AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection)); } try { m_Commandptr.CreateInstance (__uuidof(Command)); m_Recordset.CreateInstance (__uuidof(Recordset)); m_Commandptr->ActiveConnection =theApp.m_pConnection; } catch(_com_error e) { CCommon common; AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection)); } 源码网上有好多直接到www.google.com里search 一下嘛! 可以去www.vckbase.com看看,里面好多//连接HRESULT hr; hr=m_pConnection.CreateInstance("ADODB.Connection"); if(!SUCCEEDED(hr)) { AfxMessageBox("数据库初始化出错!"); return false; }CString m_username;//用户名 CString m_password;//密码 CString m_dbserver; //数据服务器名 CString m_dbtable;//数据库名CString strConnection = "Provider=SQLOLEDB.1;Data Source=" + m_dbserver + ";Initial Catalog=" + m_dbtable + ";User ID=" + m_username + "; PWD=" + m_password; try { theApp.m_pConnection->Open((_bstr_t)strConnection,"","",-1); } catch(_com_error e) { CCommon common; AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection)); } try { m_Commandptr.CreateInstance (__uuidof(Command)); m_Recordset.CreateInstance (__uuidof(Recordset)); m_Commandptr->ActiveConnection =theApp.m_pConnection; } catch(_com_error e) { CCommon common; AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection)); } MFC图像旋转问题 vc 控制台 连接MYSQL数据库 release下 程序关闭时报错 dll中的对话框 winsock编程应包括些什么头文件和库? 这类错误怎么解决? 紧急时期,请大家看一下我的作品,喜欢的帮忙投一票! CSDN有没有象大富翁一样的离线数据库或CHM文档啊?有给个网址我下下 InstallShield!再问一次,有人帮忙吗? 【求助】wix中如何判别系统位数??? 入门问题... 如何用ADO连接数据库?在windows的API编程下。 如何在当前对话框的标题中写字和放置图片
_RecordsetPtr m_Recordset;
_CommandPtr m_Commandptr;
_ConnectionPtr m_pConnection;//连接
HRESULT hr;
hr=m_pConnection.CreateInstance("ADODB.Connection");
if(!SUCCEEDED(hr))
{
AfxMessageBox("数据库初始化出错!");
return false;
}CString m_username;//用户名
CString m_password;//密码
CString m_dbserver; //数据服务器名
CString m_dbtable;//数据库名
CString strConnection = "Provider=SQLOLEDB.1;Data Source=" + m_dbserver +
";Initial Catalog=" + m_dbtable +
";User ID=" + m_username + "; PWD=" + m_password;
try
{
theApp.m_pConnection->Open((_bstr_t)strConnection,"","",-1);
}
catch(_com_error e)
{
CCommon common;
AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection));
}
try
{
m_Commandptr.CreateInstance (__uuidof(Command));
m_Recordset.CreateInstance (__uuidof(Recordset));
m_Commandptr->ActiveConnection =theApp.m_pConnection;
}
catch(_com_error e)
{
CCommon common;
AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection));
}
直接到www.google.com里search 一下嘛!
//连接
HRESULT hr;
hr=m_pConnection.CreateInstance("ADODB.Connection");
if(!SUCCEEDED(hr))
{
AfxMessageBox("数据库初始化出错!");
return false;
}CString m_username;//用户名
CString m_password;//密码
CString m_dbserver; //数据服务器名
CString m_dbtable;//数据库名
CString strConnection = "Provider=SQLOLEDB.1;Data Source=" + m_dbserver +
";Initial Catalog=" + m_dbtable +
";User ID=" + m_username + "; PWD=" + m_password;
try
{
theApp.m_pConnection->Open((_bstr_t)strConnection,"","",-1);
}
catch(_com_error e)
{
CCommon common;
AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection));
}
try
{
m_Commandptr.CreateInstance (__uuidof(Command));
m_Recordset.CreateInstance (__uuidof(Recordset));
m_Commandptr->ActiveConnection =theApp.m_pConnection;
}
catch(_com_error e)
{
CCommon common;
AfxMessageBox(common.DisplayAdoError(theApp.m_pConnection));
}