学生管理系统中,修改密码点击确定后:连接占线导致另一个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("不能打开数据库!");
}
}
}
}
}
...全文
182 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文围绕基于粒子群算法(PSO)的风电与水电(抽水蓄能)联合优化调度问题展开研究,旨在通过智能优化算法实现可再生能源的高效利用与电力系统的经济稳定运行。文系统阐述了粒子群算法的核心原理及其在电力调度的适用性,构建了综合考虑风电出力不确定性、抽水蓄能电站调节能力及系统运行约束的联合优化调度模型。采用Matlab进行算法编程与仿真求解,验证了该方法在降低系统综合运行成本、提升新能源消纳水平、增强电网调峰调频能力等方面的优越性能。研究进一步设计了多种对比场景,分析不同调度策略下的系统表现,充分展示了所提模型在应对复杂运行条件时的鲁棒性与实用价值。; 适合人群:具备一定电力系统分析基础和Matlab编程能力的研究生、科研人员,以及从事新能源并网调度、电力系统规划与运行等相关领域的工程师; 使用场景及目标:①应用于风电场与抽水蓄能电站的协同优化调度决策支持;②为高比例可再生能源接入的电力系统提供经济可靠的低碳调度方案;③服务于高校及科研院所关于智能优化算法在能源系统应用的教学与科研实验; 阅读建议:建议读者结合提供的Matlab代码深入理解算法实现细节与模型构建逻辑,重点关注目标函数设计、约束条件处理及参数设置对优化结果的影响,并通过复现仿真结果来掌握粒子群算法解决复杂非线性调度问题的关键技术要点。

22,296

社区成员

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

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