如何更新数据库中记录,求大神指点,纠正我的错误
小弟做了个“添加用户”窗体,实现了把用户名密码信息保存到Access数据库表中,并对用户名密码加密;现要做“登录”窗体,请教如何对数据库表中的字段解密,以便解密后和输入TEXT文本中的值做比对。代码如下:
程序代码:
unit Frmlogin; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; Edit2: TEdit; Button1: TButton; Button2: TButton; Edit3: TEdit; Edit4: TEdit; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses DataT; {$R *.dfm} //解密函数 Function UncrypKey(Src: String; Key: String): string; var idx: integer; KeyLen: integer; KeyPos: integer; offset: integer; dest: string; SrcPos: integer; SrcAsc: integer; TmpSrcAsc: integer; Range: integer; begin KeyLen := Length(Key); if KeyLen = 0 then Key := 'Think Space'; KeyPos := 0; SrcPos := 0; SrcAsc := 0; Range := 256; offset := StrToInt('$' + copy(Src, 1, 2)); SrcPos := 3; repeat SrcAsc := StrToInt('$' + copy(Src, SrcPos, 2)); if KeyPos < KeyLen Then KeyPos := KeyPos + 1 else KeyPos := 1; TmpSrcAsc := SrcAsc xor ord(Key[KeyPos]); if TmpSrcAsc <= offset then TmpSrcAsc := 255 + TmpSrcAsc - offset else TmpSrcAsc := TmpSrcAsc - offset; dest := dest + chr(TmpSrcAsc); offset := SrcAsc; SrcPos := SrcPos + 2; until SrcPos >= Length(Src); Result := dest; end; procedure TForm1.FormCreate(Sender: TObject); begin data.adoqlogin.close; data.adoqlogin.sql.clear; data.adoqlogin.sql.add('update users set username='张三',password='123456''); data.adoconnectBooks.connected:=true; data.adoqlogin.execsql;unit Frmlogin; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; Edit2: TEdit; Button1: TButton; Button2: TButton; Edit3: TEdit; Edit4: TEdit; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses DataT; {$R *.dfm} //解密函数 Function UncrypKey(Src: String; Key: String): string; var idx: integer; KeyLen: integer; KeyPos: integer; offset: integer; dest: string; SrcPos: integer; SrcAsc: integer; TmpSrcAsc: integer; Range: integer; begin KeyLen := Length(Key); if KeyLen = 0 then Key := 'Think Space'; KeyPos := 0; SrcPos := 0; SrcAsc := 0; Range := 256; offset := StrToInt('$' + copy(Src, 1, 2)); SrcPos := 3; repeat SrcAsc := StrToInt('$' + copy(Src, SrcPos, 2)); if KeyPos < KeyLen Then KeyPos := KeyPos + 1 else KeyPos := 1; TmpSrcAsc := SrcAsc xor ord(Key[KeyPos]); if TmpSrcAsc <= offset then TmpSrcAsc := 255 + TmpSrcAsc - offset else TmpSrcAsc := TmpSrcAsc - offset; dest := dest + chr(TmpSrcAsc); offset := SrcAsc; SrcPos := SrcPos + 2; until SrcPos >= Length(Src); Result := dest; end; procedure TForm1.FormCreate(Sender: TObject); begin data.adoqlogin.close; data.adoqlogin.sql.clear; data.adoqlogin.sql.add('update users set username='张三',password='123456''); data.adoconnectBooks.connected:=true; data.adoqlogin.execsql;
编译提示UPDATE语句出错,求解???