www.gusucode.com > VC++操作SqlServer数据库的参考源程序源码程序 > VC++操作SqlServer数据库的参考源程序源码程序/code/SetPassWord.cpp
//Download by http://www.NewXing.com // SetPassWord.cpp : implementation file // #include "stdafx.h" #include "Student.h" #include "SetPassWord.h" #include "studentdlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSetPassWord dialog extern CStudentApp theApp; CSetPassWord::CSetPassWord(CWnd* pParent /*=NULL*/) : CDialog(CSetPassWord::IDD, pParent) { //{{AFX_DATA_INIT(CSetPassWord) m_sNewPass = _T(""); m_sVerify = _T(""); //}}AFX_DATA_INIT } void CSetPassWord::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSetPassWord) DDX_Text(pDX, IDC_NewPass, m_sNewPass); DDX_Text(pDX, IDC_Verify, m_sVerify); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSetPassWord, CDialog) //{{AFX_MSG_MAP(CSetPassWord) ON_BN_CLICKED(IDC_TRUE, OnTrue) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSetPassWord message handlers void CSetPassWord::OnTrue() { _variant_t RecordsAffected; char buf[100]; UpdateData(TRUE); sprintf(buf,"update users set password = \'%s\' where username=\'%s\'",m_sNewPass,theApp.m_sUserName ); if(!(m_sNewPass==m_sVerify)) { MessageBox("密码不一致!"); m_sVerify=""; UpdateData(TRUE); return; } try { theApp.m_pConnect->Execute(buf,&RecordsAffected,adCmdText); MessageBox("密码修改成功!"); CDialog::OnOK(); } catch(_com_error e) { AfxMessageBox(e.ErrorMessage()); } }