delphi7中用DBCombobox会修改数据库记录?
刚才用delphi写了一个用户登陆界面大致就是用DBCombobox读取数据库中的用户名然后输密码验证然后发现调试时数据库的用户名一项会有被修改的现象。。。。太奇怪了只是...
刚才用delphi写了一个用户登陆界面 大致就是用DBCombobox读取数据库中的用户名 然后输密码验证 然后发现调试时数据库的用户名一项会有被修改的现象。。。。太奇怪了 只是一个登陆界面 根本,没往数据库写数据啊。。。
求大神解释- -!
附上代码。。。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, DBTables, Buttons;
type
TLoginForm = class(TForm)
Edit1: TEdit;
DBComboBox1: TDBComboBox;
DataSource1: TDataSource;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Table1: TTable;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
LoginForm: TLoginForm;
implementation
uses Unit2;
{$R *.dfm}
procedure TLoginForm.FormCreate(Sender: TObject);
var
i,count:integer;
begin
count:=Table1.RecordCount;
for i:=0 to count-1 do
begin
DBComboBox1.Items.Add(table1.fields[1].asstring);
table1.next;
end;
table1.first;
end;
procedure TLoginForm.BitBtn2Click(Sender: TObject);
begin
LoginForm.close;
end;
procedure TLoginForm.BitBtn1Click(Sender: TObject);
var
j,count,index:integer;
name,password:string;
begin
count:=Table1.RecordCount;
table1.First;
for j:=0 to count-1 do
begin
if (table1.fields[1].asstring=dbcombobox1.text) and (table1.fields[2].asstring=edit1.Text) then
begin
mainform.show;
LoginForm.hide;
table1.First;
exit;
end;
table1.Next;
end;
showmessage('用户名或密码错误!');
end; 展开
求大神解释- -!
附上代码。。。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, DBTables, Buttons;
type
TLoginForm = class(TForm)
Edit1: TEdit;
DBComboBox1: TDBComboBox;
DataSource1: TDataSource;
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Table1: TTable;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
LoginForm: TLoginForm;
implementation
uses Unit2;
{$R *.dfm}
procedure TLoginForm.FormCreate(Sender: TObject);
var
i,count:integer;
begin
count:=Table1.RecordCount;
for i:=0 to count-1 do
begin
DBComboBox1.Items.Add(table1.fields[1].asstring);
table1.next;
end;
table1.first;
end;
procedure TLoginForm.BitBtn2Click(Sender: TObject);
begin
LoginForm.close;
end;
procedure TLoginForm.BitBtn1Click(Sender: TObject);
var
j,count,index:integer;
name,password:string;
begin
count:=Table1.RecordCount;
table1.First;
for j:=0 to count-1 do
begin
if (table1.fields[1].asstring=dbcombobox1.text) and (table1.fields[2].asstring=edit1.Text) then
begin
mainform.show;
LoginForm.hide;
table1.First;
exit;
end;
table1.Next;
end;
showmessage('用户名或密码错误!');
end; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询