学生管理系统中,修改密码点击确定后:连接占线导致另一个hstmt

monkeyfly007 2015-07-08 07:14:53
我在做一个课程设计,学生成绩管理系统可是为什么会出现这个问题?在修改密码界面,点击确定时就弹出这个错误窗口,不知道怎么回事。(是不是没有释放对象还是?问题见代码[User]部分)

void CMyDialog::OnOK() //用户登录界面,确定按钮
{
// TODO: Add extra validation here
CString Username,Password;
m_username.GetWindowText(Username);
m_password.GetWindowText(Password);
if(!m_database.IsOpen())
{
if(m_database.Open(_T("student")))
{
m_recordset.m_pDatabase=&m_database;
CString strSQL;
strSQL.Format("select * from [User] where User_name='%s' and User_password='%s'",Username,Password);
m_recordset.Open(CRecordset::forwardOnly,strSQL);
if(m_recordset.GetRecordCount()==0)
{
MessageBox("用户名或密码错误!","错误!",MB_OK|MB_ICONWARNING);
m_password.SetWindowText("");
m_password.SetFocus();
}
else
{
//m_recordset.GetFieldValue("");
CDialog::OnOK();
}
}
m_recordset.Close();
m_database.Close();
}
else
{
MessageBox("不能打开数据库!");
}
//CDialog::OnOK();
}

void CPasswordDlg::OnOK() //修改密码界面,确定按钮
{
// TODO: Add extra validation here
CString Username,Password,Newpassword,Confirmpassword;
m_username.GetWindowText(Username);
m_password.GetWindowText(Password);
m_new.GetWindowText(Newpassword);
m_confirm.GetWindowText(Confirmpassword);

CDatabase m_database;
CRecordset m_recordset;
if(Newpassword.IsEmpty()||Confirmpassword.IsEmpty())
{
MessageBox("密码不能为空!");
}
else
{
if(Newpassword!=Confirmpassword)
{
MessageBox("两次密码不一致,请重新输入密码");
m_new.SetWindowText("");
m_confirm.SetWindowText("");
m_new.SetFocus();
}
else
{
if(!m_database.IsOpen())
{
if(m_database.Open(_T("student")))
{
m_recordset.m_pDatabase=&m_database;
CString strSQL;
strSQL.Format("select * from [User] where User_name='%s' and User_password='%s'",Username,Password);
m_recordset.Open(CRecordset::forwardOnly,strSQL);
if(m_recordset.GetRecordCount()==0)
{
MessageBox("用户名或密码错误!","错误!",MB_OK|MB_ICONWARNING);
m_password.SetWindowText("");
m_new.SetWindowText("");
m_confirm.SetWindowText("");
m_password.SetFocus();
}
else
{
strSQL.Format("update [User] set User_password='%s' where User_name='%s'",Newpassword,Username);
m_database.ExecuteSQL(strSQL);
MessageBox("修改密码成功");
CDialog::OnOK();
}
m_recordset.Close();
m_database.Close();
}
else
{
MessageBox("不能打开数据库!");
}
}
}
}
}
...全文
131 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
对日常债务进行数据库操作 .586 .model flat,stdcall option casemap:none include pay.inc include p_Func.asm include p_const.asm include p_struct.asm include p_data.asm include macro.mac .data hInstance HINSTANCE ? CommandLine LPSTR ? hParent dword ? hCursor dword ? hconn_g dword ? henv_g dword ? hstmt_g dword ? dwCount_g dword ? bFlag_g dword ? pPayForData_g PAYFORDATA <> pConfigData CONFIGDATA <> .code include p_code.asm include p_db.asm include p_Dialog.asm include p_ListView.asm include P_ini.asm include p_html.asm ; --------------------------------------------------------------------------- start: invoke GetModuleHandle, NULL mov hInstance,eax invoke DialogBoxParam,hInstance,addr LoginDlgName,0,addr LoginDialog,NULL .if bFlag_g invoke GetCommandLine mov CommandLine,eax invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT .endif invoke ExitProcess,eax WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD LOCAL wc:WNDCLASSEX LOCAL msg:MSG LOCAL hwnd:HWND LOCAL hMenu:HWND LOCAL hAccelerator:HWND mov wc.cbSize,SIZEOF WNDCLASSEX mov wc.style, CS_HREDRAW or CS_VREDRAW mov wc.lpfnWndProc, OFFSET WndProc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL push hInstance pop wc.hInstance mov wc.hbrBackground,COLOR_BTNFACE+1 mov wc.lpszMenuName,offset MenuName mov wc.lpszClassName,OFFSET ClassName invoke LoadIcon,NULL,IDI_MAIN_ICON mov wc.hIcon,eax mov wc.hIconSm,eax mov hMainIco,eax invoke LoadMenu,hInstance,IDR_MENU mov hMenu,eax invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax invoke LoadCursor,hInstance,IDI_HANDLE_ICON mov hCursor,eax invoke LoadAccelerators,hInstance,IDA_ACCELERATOR mov hAccelerator,eax invoke RegisterClassEx, addr wc INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\ WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\ CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,hMenu,\ hInst,NULL mov hwnd,eax mov hParent,eax invoke ShowWindow, hwnd,SW_SHOWNORMAL invoke UpdateWindow, hwnd .WHILE TRUE invoke GetMessage, ADDR msg,NULL,0,0 .BREAK .IF (!eax) invoke TranslateAccelerator,hwnd,hAccelerator,addr msg .if eax == 0 invoke TranslateMessage, ADDR msg invoke DispatchMessage, ADDR msg .endif .ENDW mov eax,msg.wParam ret WinMain endp WndProc proc uses ebx hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM local @stFont:LOGFONT,@hFont:DWORD LOCAL @dwColor:dword .IF uMsg==WM_DESTROY invoke KillTimer,hWnd,IDC_TIMER_STATUSBAR invoke PostQuitMessage,NULL .elseif uMsg==WM_TIMER .if wParam==IDC_TIMER_STATUSBAR invoke _PrintMsg_3 .endif .ELSEIF uMsg==WM_CREATE invoke SetTimer,hWnd,IDC_TIMER_STATUSBAR ,1000,NULL invoke LoadIcon,hInstance,IDI_MAIN_ICON invoke SendMessage, hWnd, WM_SETICON, ICON_BIG,eax ;control invoke _DoToolBar,hInstance,hWnd,IDC_MAIN_TB mov hToolBar,eax ;invoke _DoEdit,hInstance,hToolBar,IDC_MAIN_EDIT ;mov hEdit,eax ;invoke _DoButton,hInstance,hToolBar,IDC_MAIN_BUTTON,_T("搜索") ;mov hButton,eax ;LABEL invoke _DoLabel,hInstance,hToolBar,IDC_BTN_LABEL_3,200,3,150,20 invoke SetDlgItemText,hToolBar,IDC_BTN_LABEL_3,_T("当前用户:") invoke _DoLabel,hInstance,hToolBar,IDC_BTN_LABEL_NAME,270,3,150,20 invoke _DoLabel,hInstance,hToolBar,IDC_BTN_LABEL_1,340,3,150,20 invoke SetDlgItemText,hToolBar,IDC_BTN_LABEL_1,_T("借入:") invoke _DoLabel,hInstance,hToolBar,IDC_BTN_LABEL_IN,380,3,150,20 invoke _DoLabel,hInstance,hToolBar,IDC_BTN_LABEL_2,480,3,150,20 invoke SetDlgItemText,hToolBar,IDC_BTN_LABEL_2,_T("借出:") invoke _DoLabel,hInstance,hToolBar,IDC_BTN_LABEL_OUT,520,3,150,20 invoke _DoStatusBar,hInstance,hWnd,IDC_MAIN_SB mov hStatusBar,eax invoke _DoListView,hInstance,hWnd,IDC_MAIN_LSV mov hListView ,eax invoke _InsertColumnToMainListV,hListView invoke _DoPopupMainMenu, hInstance,hWnd mov hPopupMainMenu,eax invoke _InitConfig,hWnd .elseif uMsg==WM_NOTIFY push edi mov edi, lParam mov eax, [edi.NMHDR].hwndFrom .if eax==hListView .if [edi.NMHDR].code==NM_DBLCLK ;双击 .elseif [edi.NMHDR].code==NM_CLICK ;单击 invoke _GetCurrentFocus,hListView,addr pPayForData_g .elseif [edi.NMHDR].code==NM_RCLICK ;右击 invoke _GetCurrentFocus,hListView,addr pPayForData_g invoke _ShowPopupMainMenu,hWnd,hPopupMainMenu .endif .endif pop edi .elseif uMsg==WM_COMMAND .if lParam !=0 ;工具栏 LOWORD wParam .if eax==IDC_TBB_NEW invoke DialogBoxParam,hInstance,addr NewDlgName,hWnd,addr IddNewDialog,NULL .elseif eax==IDC_TBB_SEE invoke DialogBoxParam,hInstance,addr SeeDlgName,hWnd,addr SeeDialog,NULL .elseif eax==IDC_TBB_PRINT invoke _Print_Html,hWnd .elseif eax==IDC_TBB_HELP invoke DialogBoxParam,hInstance,addr AboutDlgName,hWnd,addr AboutDialog,NULL .elseif eax==IDC_TBB_EXIT invoke SendMessage,hWnd,WM_CLOSE,0,0 .endif .elseif lParam ==0 HIWORD wParam .if eax==0 ;菜单栏 mov eax,wParam .if ax==IDM_NEW invoke DialogBoxParam,hInstance,addr NewDlgName,hWnd,addr IddNewDialog,NULL invoke _RefreshMTData,hWnd,hListView .elseif ax==IDM_SEE invoke DialogBoxParam,hInstance,addr SeeDlgName,hWnd,addr SeeDialog,NULL .elseif ax==IDM_PRINT invoke _Print_Html,hWnd .elseif ax==IDM_CALC invoke _OpenProgramExeFile,hWnd,addr SZCALC,NULL .elseif ax==IDM_HELP invoke DialogBoxParam,hInstance,addr AboutDlgName,hWnd,addr AboutDialog,NULL .elseif ax==IDM_PWD invoke DialogBoxParam,hInstance,addr PwdDlgName,hWnd,addr PwdDialog,NULL .elseif ax==IDM_REFRESH invoke _RefreshMTData,hWnd,hListView .elseif ax==IDM_DEMO invoke DialogBoxParam,hInstance,addr DemoDlgName,hWnd,addr DemoDialog,NULL .elseif ax==IDM_CAL invoke _PromptMsg,_T("建设...") .endif .elseif eax==1 ;快捷键 .endif .endif .elseif uMsg ==WM_SIZE .if wParam!=SIZE_MINIMIZED invoke SendMessage,hStatusBar,uMsg,wParam,lParam invoke SendMessage,hToolBar,uMsg,wParam,lParam mov eax,lParam mov edx,eax and eax,0ffffh shr edx,16 sub edx,46 invoke MoveWindow,hListView, 0, 28, eax,edx,TRUE mov eax,lParam and eax,0ffffh mov ebx,eax sub eax,210 sub ebx,55 invoke MoveWindow,hEdit, eax, 3,150,20,TRUE invoke MoveWindow,hButton,ebx, 3,50,20,TRUE .endif .elseif uMsg==WM_SIZING LimitWindowWidth 455 LimitWindowHeight 455 .ELSE invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .ENDIF xor eax,eax ret WndProc endp _RefreshMTData proc hWnd:dword,hOwner:dword pushad ;连接数据库 invoke DBConnect,hWnd .if eax invoke _PrintMsg_1,_T("数据库连接成功!") .endif ;显示数据 invoke SQLExecDirect,hstmt_g,addr SHOW_ALL_RECODE_MT,sizeof SHOW_ALL_RECODE_MT .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO ;73570000h invoke _ReadMTToMainListV,hOwner,hstmt_g mov dwCount_g,eax invoke _PrintMsg_2,dwCount_g,_T(" ") invoke _PrintMsg_1,_T("加载成功!") .endif invoke DisDBConnect,hWnd .if eax invoke _PrintMsg_1,_T("断开与数据库的连接!") .endif popad ret _RefreshMTData endp _RefreshOPData proc hWnd:dword,hOwner:dword LOCAL @nCount:dword pushad ;连接数据库 invoke DBConnect,hWnd .if eax invoke _PrintMsg_1,_T("数据库连接成功!") .endif ;显示数据 invoke SQLExecDirect,hstmt_g,addr SHOW_ALL_RECODE_OP,sizeof SHOW_ALL_RECODE_OP .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO ;73570000h invoke _ReadOPToSeeListV,hOwner,hstmt_g mov @nCount,eax invoke _SetGroupText,hWnd,@nCount invoke _PrintMsg_1,_T("加载成功!") .endif invoke DisDBConnect,hWnd .if eax invoke _PrintMsg_1,_T("断开与数据库的连接!") .endif popad ret _RefreshOPData endp _InitConfig proc hWnd:dword LOCAL @Buff[MAX_PATH]:byte pushad invoke _RefreshMTData,hWnd,hListView invoke SetDlgItemText,hToolBar,IDC_BTN_LABEL_NAME,addr pConfigData.szName invoke _CalcMTPayForRecord,hWnd,addr pConfigData.szName,FALSE mov dwMoneyIn,eax invoke wsprintf,addr @Buff,addr szMoney,dwMoneyIn invoke SetDlgItemText,hToolBar,IDC_BTN_LABEL_IN,addr @Buff invoke _CalcMTPayForRecord,hWnd,addr pConfigData.szName,TRUE mov dwMoneyOut,eax invoke wsprintf,addr @Buff,addr szMoney,dwMoneyOut invoke SetDlgItemText,hToolBar,IDC_BTN_LABEL_OUT,addr @Buff ;TITLE invoke RtlZeroMemory,addr @Buff,sizeof @Buff invoke lstrcpy,addr @Buff,addr pConfigData.szAppName invoke lstrcat,addr @Buff,_T(" -- ") invoke lstrcat,addr @Buff,addr pConfigData.szName invoke SendMessage,hWnd,WM_SETTEXT,0,addr @Buff popad ret _InitConfig endp end start

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧