CString con ;
con.Format("driver={SQLServer};Server=192.168.8.23;DATABASE=du.mdb;UID="";PWD=123");
m_pConnection->Open(_bstr_t(con),"","",adModeUnknown) ;
为什么我这条语句连接不上我要的数据库??????
con.Format("driver={SQLServer};Server=192.168.8.23;DATABASE=du.mdb;UID="";PWD=123");
m_pConnection->Open(_bstr_t(con),"","",adModeUnknown) ;
为什么我这条语句连接不上我要的数据库??????
{
if (m_strService.IsEmpty())
{
::MessageBox(NULL,"·þÎñÃû²»ÄÜΪ¿Õ","Ìáʾ",MB_OK);
return FALSE;
}
if (m_strDatabase.IsEmpty())
{
::MessageBox(NULL,"Êý¾Ý¿â²»ÄÜΪ¿Õ","Ìáʾ",MB_OK);
return FALSE;
} theApp.m_pConnection.CreateInstance(__uuidof(Connection));
try
{
theApp.m_strDatabase=m_strDatabase; CString strConn;
strConn="Provider=SQLOLEDB.1;Password=";
strConn+=m_strPassword;
strConn+=";Persist Security Info=True;User ID=";
strConn+=m_strUsername;
strConn+=";Initial Catalog=";
strConn+=m_strDatabase;
strConn+=";Data Source=";
strConn+=m_strService;
theApp.m_pConnection->Open((_bstr_t)strConn,
"",
"",
adModeUnknown);
}
catch(_com_error e)
{
::MessageBox(NULL,e.Description(),"Ìáʾ",MB_OK);
return FALSE;
}
::MessageBox(NULL,"Êý¾Ý¿âÁ¬½Ó³É¹¦£¡","Ìáʾ",MB_OK);
return TRUE;}
http://dev.csdn.net/article/45/45792.shtm