_RecordsetPtr
void CMyDlg::OnOK()
{
// TODO: Add extra validation here
// TODO: Add your control notification handler code here
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst=(__uuidof(RecordsetPtr));
pConn->ConnectionString="Driver={MYSQL ODBC 5.1 Driver};Server=localhost;Database=jiang;User=root;Password=jiang;Option=3";
pConn->Open("","","",adConnectUnspecified);
pRst=pConn->Execute("select *from login",NULL,adCmdText);
CString str1,str2,str3;
GetDlgItem(IDC_EDIT1)->GetWindowText(str1);
while(!pRst->rsEOF)
{
if(str1==(_bstr_t)pRst->GetCollect("UserName"))
{
MessageBox("该用户名已存在!");
return;
}
pRst->MoveNext();
}
GetDlgItem(IDC_EDIT2)->GetWindowText(str2);
GetDlgItem(IDC_EDIT3)->GetWindowText(str3);
if(str2!=str3)
{
MessageBox("密码不一致!");
return;
}
else
{
pRst->AddNew();
pRst->PutCollect("UserName",_variant_t(str2));
pRst->PutCollect("UserName",_variant_t(str3));
pRst->Update();
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
MessageBox("注册成功!");
CDialog::OnOK();
}
调试的时候运行到pRst->AddNew();时出错,,,,