Recordset
-
eduardosic
- Posts: 387
- Joined: Fri 18 Nov 2005 00:26
- Location: Brazil
wait...
wait.. be patient..djedai wrote:Hey SOmeone Can Help me or all in this forum dead.
Just assign a command to the SQL property, and call Open to get a recordset. The command must return data. You can link with TMyQuery a DB-aware control like TDBGrid, or a set of controls like TDBEdit to browse and edit data. To access data programmatically, use the FieldByName property. To scroll through the recordset use Next, Prior, First, Last methods.
For example see demo projects included in MyDAC. Also see the description of properties and methods mentioned above and others in the Delphi help.
For example see demo projects included in MyDAC. Also see the description of properties and methods mentioned above and others in the Delphi help.
Code: Select all
procedure TForm1.SetCurrentAccessLevel;
var
i:integer;
AccLvl:integer;
begin
if not flSelected then exit;
Query .Close;
Query .SQL.Text:='SELECT [User],[Password],[AccessLevel] FROM One WHERE [User]='''+CurName+'''';
try
Query .Open;
except
end;
if Query .RecordCount = 0 then
ShowMessage('Нет такого юзера.')
else
try
AccLvl:=Query .Recordset.Collect[2];
if string(Query .Recordset.Collect[1])=CurPass then
for i:=0 to Form1.ComponentCount-1 do
begin
if Form1.Components[i].Tag= 0 then continue else
if (Form1.Components[i] is TControl)then (Form1.Components[i] as TControl).Enabled :=AccLvl>=Form1.Components[i].Tag
else if (Form1.Components[i] is TMenuItem)then (Form1.Components[i] as TMenuItem).Enabled :=AccLvl>=Form1.Components[i].Tag;
end
else ShowMessage('Неправильный пароль.');
except
ShowMessage('Неудачно.');
end;
flSelected:=false;
end;
-
eduardosic
- Posts: 387
- Joined: Fri 18 Nov 2005 00:26
- Location: Brazil
try this..
try this..
Code: Select all
procedure TForm1.SetCurrentAccessLevel;
var
i:integer;
AccLvl:integer;
begin
if not flSelected then
exit;
Query .Close;
Query .SQL.Text:='SELECT User, Password, AccessLevel FROM One WHERE User='''+CurName+'''';
try
Query .Open;
except
end;
if Query .RecordCount = 0 then
ShowMessage('Нет такого юзера.')
else
try
AccLvl := Query.FieldByName( 'AccessLevel' ).AsInteger;
if Query.FieldByName( 'Password' ).AsString =CurPass then
for i:=0 to Form1.ComponentCount-1 do
begin
if Form1.Components[i].Tag= 0 then
continue
else
if (Form1.Components[i] is TControl) then
(Form1.Components[i] as TControl).Enabled :=AccLvl>=Form1.Components[i].Tag
else if (Form1.Components[i] is TMenuItem)then (Form1.Components[i] as TMenuItem).Enabled :=AccLvl>=Form1.Components[i].Tag;
end
else ShowMessage('Неправильный пароль.');
except
ShowMessage('Неудачно.');
end;
flSelected:=false;
end;