vc++通过ADO连接数据库连接字符串的问题!!!!
_ConnectionPtrpCon(__uuidof(Connection));pCon->ConnectionString="MSSQLSERVER;Integrat...
_ConnectionPtr pCon(__uuidof(Connection));
pCon->ConnectionString="MSSQLSERVER;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Student"; 请问此链接字符串应该如何书写,我用的本地数据库windows 身份验证模式 数据库服务器名字是RW6YXGLAY8R6JMB 数据库名称是student ,望高手指点 展开
pCon->ConnectionString="MSSQLSERVER;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Student"; 请问此链接字符串应该如何书写,我用的本地数据库windows 身份验证模式 数据库服务器名字是RW6YXGLAY8R6JMB 数据库名称是student ,望高手指点 展开
展开全部
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)
{
}
}
{
// 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)
{
}
}
更多追问追答
追问
追答
你是不是没有初始化com组件
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询