VC ???????????С??
???????????? ???????[ 2013/11/4 11:49:41 ] ????????
??????VC??MFC??????SQL Server???????????afxoleinit???????????????????????????????
void smsLogon::InitSQLServer(CString server?? CString db?? CString UserName?? CString Pwd)
{
m_pConnection.CreateInstance("ADODB.Connection");
CString strCn;
strCn.Empty();
strCn="provider=SQLOLEDB;data source="+server
+";initial catalog="+db
+";userID="+UserName
+";PassWord="+Pwd;
_variant_t bcnstr=_variant_t(strCn);
_variant_t bunstr=_variant_t(UserName);
_variant_t bpwdstr=_variant_t(Pwd);
//?????????
try
{
m_pConnection->Open(_bstr_t(bcnstr)??_bstr_t(bunstr)??
_bstr_t(bpwdstr)??-1);//adOpenUnspecified
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("Warning: ?????????????. ???????: %s; ???: %s; ??: %d
"?? e.ErrorMessage()?? __FILE__?? __LINE__);
AfxMessageBox(errormessage);
}
catch(...)
{
AfxMessageBox("Warning :??????????????δ?????");
}
}
void smsLogon::ExitDB() //????????????????
{
if(m_pConnection!=NULL)
{
m_pConnection->Close();//???????
m_pConnection.Release();//??????
}
}
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11