try {
//OK//_bstr_t strConnect="Provider=SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=sa;Initial Catalog=dataSource;Data Source=127.0.0.1,1433;providerName=System.Data.SqlClient";
_bstr_t strConnect="Provider=SQLOLEDB;Password=123456;User ID=sa;Server=USERXXJ\SQPC;Initial Catalog=dataSource";
sqlSp->Open(strConnect,"","",adModeUnknown);
}
catch(_com_error &e) {
cout<< "OPEN ERROR !" << e.Description()<<endl;
//return 0;
}
用IP 連接可以通過,但是用計算機名稱無法連接數據庫(下面的連接);提示:SQL不存在或拒絕訪問;
可以用了 但是還要謝謝你的回答; 貼碼啦:_bstr_t strConnect="Provider=SQLOLEDB.1;Password=123456;User ID=sa;Data Source=XXX-PC\實例名;Initial Catalog=data;Connect Timeout=20;providerName=System.Data.SqlClient";