数据库是 my-data在安装数据库时将sa 密码设为1234 混合模式 ADO方式
第一次写数据库程序 好多地方不太明白 希望 大家赐教 //初始化COM环境
::CoInitialize(NULL); //创建连接对象和记录集对象
HRESULT hr;
try
{
hr=m_Con.CreateInstance("ADODB.Connection");
if(SUCCEEDED (hr))
{ hr=m_Con->Open("Data Source=(local);Initial Catalog=my-data;User Id=sa;Password=1234",
"","",adModeUnknown);
}
}
catch(_com_error e)
{
CString str;
str.Format("连接数据库失败:%s",e.ErrorMessage());
AfxMessageBox(str); }
m_pRec.CreateInstance(__uuidof(Recordset));
第一次写数据库程序 好多地方不太明白 希望 大家赐教 //初始化COM环境
::CoInitialize(NULL); //创建连接对象和记录集对象
HRESULT hr;
try
{
hr=m_Con.CreateInstance("ADODB.Connection");
if(SUCCEEDED (hr))
{ hr=m_Con->Open("Data Source=(local);Initial Catalog=my-data;User Id=sa;Password=1234",
"","",adModeUnknown);
}
}
catch(_com_error e)
{
CString str;
str.Format("连接数据库失败:%s",e.ErrorMessage());
AfxMessageBox(str); }
m_pRec.CreateInstance(__uuidof(Recordset));
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货