void CTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
try{ HRESULT hr;
CString sql;
sql="Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=student ;Data Source=192.168.2.134";//你是SQL的话最好写IP,不要写服务器名
hr = this->m_pConnection.CreateInstance("ADODB.Connection");
if(SUCCEEDED(hr))
{
hr = this->m_pConnection->Open( (_bstr_t)sql,"","",adModeUnknown);
}
}catch(_com_error e)
{
}
}