关于ADO连接SQL数据库的一个问题!

来源:百度知道 编辑:UC知道 时间:2024/06/16 01:20:47
void CMyDlg::OnButtonOK()
{

_ConnectionPtr pConn;
pConn.CreateInstance("ADODB.Connection");
_bstr_t strConnect="Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;InitialCatalog=UserMan;Data Sourcre=Localhost;";
pConn->Open(strConnect,"","",adModeUnknown);
if(pConn->State==adStateOpen)
MessageBox("连接数据库");

}

我写了上面的代码想连接数据库!
编译通过
可是执行时弹出了this application has requested the runtime to terminate it in an unusual way
这是什么问题啊?

这个申请需要一定的运行时间,来以非正常途径终止它(指某程序)

是不是开始时,你强行关闭窗口了。还是怎么。。。

把项目结束运行。。重新编译运行下。。试试。。
不行的话,连数据库也重启动一下。