连接SQL错误:Invalid Pointer 这个错误是怎么回事呀?我应该怎么解决呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 AfxOleInit(); _ConnectionPtr m_pConn; CString m_sConn="Provider=SQLOLEDB.1;Data Source=127.0.0.1;Initial Catalog=CFAS_FP"; m_pConn.CreateInstance("ADODB.Connection"); try { HRESULT hr=m_pConn->Open((_bstr_t)m_sConn,"fpadmin","ncust",adModeUnknown); if (FAILED(hr)) { AfxMessageBox("HR错误!"); return FALSE; } } catch(_com_error e) { CString errormessage; errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage);//ÏÔʾ´íÎóÐÅÏ¢ } _ConnectionPtr m_pMyConnect=NULL; HRESULT hr=m_pMyConnect.CreateInstance(__uuidof(Connection)); if(FAILED(hr)) { AfxMessageBox("Hr Error!"); return FALSE; } _bstr_t strConnect="Provider=SQLOLEDB; Server=local;" "Database=CFAS_FP; uid=fpadmin; pwd=ncust;"; //connecting to the database server now: try { m_pMyConnect->Open(strConnect,"fpadmin","ncust",NULL); } catch (_com_error e) { CString errormessage; errormessage.Format("连接数据库错误!\r\n错误信息:%s",e.ErrorMessage()); AfxMessageBox(errormessage); }这样也有问题!晕! 不过现在的错误是Unspecified Error 可是我用sa也不行呀。我更改了用户密码后是不是要重启SQL呢? 重新咨询,如何给主框架的菜单修改文字 自定义控件 能不能钩住应用程序的所有动作? 为什么我做的窗口scroll不能动?? mfc中函数指针的一个问题,求解(50分) 多线程演示求助 请问如何遍历一条listbox记录就删除该条,并不影响遍历? 初学VC看什么书好? 请教使用CFtpConnection上传文件时,想显示上传进度怎么做?? 动态显示数字问题? 哪位有流媒体播放开发的经验和相关资料啊, 用ADO访问SQL 2000数据库遇到的问题,急!
_ConnectionPtr m_pConn;
CString m_sConn="Provider=SQLOLEDB.1;Data Source=127.0.0.1;Initial Catalog=CFAS_FP"; m_pConn.CreateInstance("ADODB.Connection");
try
{
HRESULT hr=m_pConn->Open((_bstr_t)m_sConn,"fpadmin","ncust",adModeUnknown);
if (FAILED(hr))
{
AfxMessageBox("HR错误!");
return FALSE;
}
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);//ÏÔʾ´íÎóÐÅÏ¢
}
HRESULT hr=m_pMyConnect.CreateInstance(__uuidof(Connection));
if(FAILED(hr))
{
AfxMessageBox("Hr Error!");
return FALSE;
} _bstr_t strConnect="Provider=SQLOLEDB; Server=local;"
"Database=CFAS_FP; uid=fpadmin; pwd=ncust;";
//connecting to the database server now:
try
{
m_pMyConnect->Open(strConnect,"fpadmin","ncust",NULL);
}
catch (_com_error e)
{
CString errormessage;
errormessage.Format("连接数据库错误!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);
}
这样也有问题!晕!
我更改了用户密码后是不是要重启SQL呢?