O
oldwolf202
Unregistered / Unconfirmed
GUEST, unregistred user!
我用C++builder编写一个用户注册和修改密码的程序,使用ADO控件访问本机ACCESS数据库
我编写的程序如下:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "login1.h"
#include "RIGHT2.h"
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ADOQuery1->Open();
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("Select USERCODE,USERNAME,PASSWORD from USER_INFO where USERCODE='"+Edit1->Text+"'");
if(Edit1->Text=="")
{ShowMessage("请输入帐户名!");
return;
}
if(NewAcctNameEdit->Text=="")
{ShowMessage("请输入用户名!");
return;
}
ADOQuery1->Open();
if (!(ADOQuery1->IsEmpty()))
{ShowMessage("此帐户已存在!");
return;
}
ADOQuery1->Append();
if(NewAcctCommentEdit->Text!=NewAcctPwdConfirmMaskEdit->Text)
{ShowMessage("两次输入密码不相同");
return;
}
ADOQuery1->FieldByName("USERCODE")->AsString=Edit1->Text;
ADOQuery1->FieldByName("USERNAME")->AsString=NewAcctNameEdit->Text;
ADOQuery1->FieldByName("PASSWORD")->AsString=NewAcctCommentEdit->Text;
ADOQuery1->Post();
ADOQuery1->Close();
ADOQuery1->Open();
Form2->Show();
Form1->Hide();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1->Text="";
NewAcctNameEdit->Text="";
NewAcctCommentEdit->Text="";
NewAcctPwdConfirmMaskEdit->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("Select USERCODE,PASSWORD from USER_INFO where USERCODE='"+EditAcctNameEdit->Text+"'");
ADOQuery1->Open();
if(EditAcctNameEdit->Text=="")
{ShowMessage("请输入帐户名!");
return;
}
if(ADOQuery1->IsEmpty())
{ShowMessage("此帐户不存在!");
return;
}
if(EditAcctOldPwdMaskEdit->Text=="")
{ShowMessage("请输入旧密码!");
return;
}
if(EditAcctOldPwdMaskEdit->Text!=ADOQuery1->FieldByName("PASSWORD")->AsString);
{ShowMessage("旧密码错误!");
return;
}
ShowMessage("旧密码正确");
if(EditAcctNewPwdMaskEdit->Text!=EditAcctPwdConfirmMaskEdit->Text)
{ShowMessage("两次输入的密码不相同!");
return;
}
ADOQuery1->Append();
ADOQuery1->FieldByName("PASSWORD")->AsString=EditAcctNewPwdMaskEdit->Text;
ADOQuery1->Post();
ADOQuery1->Close();
ShowMessage("新密码已生效!");
return;
}
//---------------------------------------------------------------------------
程序编译通过
用户注册部分程序没有问题
但是修改密码部分不管我输入的旧密码是对的还是错的,程序都会弹出“旧密码错误”的提示筐,请问是什么原因,应该怎么改正,在线等,急用!
解决立即给分。
我编写的程序如下:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "login1.h"
#include "RIGHT2.h"
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ADOQuery1->Open();
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("Select USERCODE,USERNAME,PASSWORD from USER_INFO where USERCODE='"+Edit1->Text+"'");
if(Edit1->Text=="")
{ShowMessage("请输入帐户名!");
return;
}
if(NewAcctNameEdit->Text=="")
{ShowMessage("请输入用户名!");
return;
}
ADOQuery1->Open();
if (!(ADOQuery1->IsEmpty()))
{ShowMessage("此帐户已存在!");
return;
}
ADOQuery1->Append();
if(NewAcctCommentEdit->Text!=NewAcctPwdConfirmMaskEdit->Text)
{ShowMessage("两次输入密码不相同");
return;
}
ADOQuery1->FieldByName("USERCODE")->AsString=Edit1->Text;
ADOQuery1->FieldByName("USERNAME")->AsString=NewAcctNameEdit->Text;
ADOQuery1->FieldByName("PASSWORD")->AsString=NewAcctCommentEdit->Text;
ADOQuery1->Post();
ADOQuery1->Close();
ADOQuery1->Open();
Form2->Show();
Form1->Hide();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1->Text="";
NewAcctNameEdit->Text="";
NewAcctCommentEdit->Text="";
NewAcctPwdConfirmMaskEdit->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("Select USERCODE,PASSWORD from USER_INFO where USERCODE='"+EditAcctNameEdit->Text+"'");
ADOQuery1->Open();
if(EditAcctNameEdit->Text=="")
{ShowMessage("请输入帐户名!");
return;
}
if(ADOQuery1->IsEmpty())
{ShowMessage("此帐户不存在!");
return;
}
if(EditAcctOldPwdMaskEdit->Text=="")
{ShowMessage("请输入旧密码!");
return;
}
if(EditAcctOldPwdMaskEdit->Text!=ADOQuery1->FieldByName("PASSWORD")->AsString);
{ShowMessage("旧密码错误!");
return;
}
ShowMessage("旧密码正确");
if(EditAcctNewPwdMaskEdit->Text!=EditAcctPwdConfirmMaskEdit->Text)
{ShowMessage("两次输入的密码不相同!");
return;
}
ADOQuery1->Append();
ADOQuery1->FieldByName("PASSWORD")->AsString=EditAcctNewPwdMaskEdit->Text;
ADOQuery1->Post();
ADOQuery1->Close();
ShowMessage("新密码已生效!");
return;
}
//---------------------------------------------------------------------------
程序编译通过
用户注册部分程序没有问题
但是修改密码部分不管我输入的旧密码是对的还是错的,程序都会弹出“旧密码错误”的提示筐,请问是什么原因,应该怎么改正,在线等,急用!
解决立即给分。