Recordset

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
djedai
Posts: 4
Joined: Fri 12 Oct 2007 17:51

Recordset

Post by djedai » Fri 12 Oct 2007 18:02

Hi. I have one question.. for u components.
Standart components query have parammetr Recordset
i ask as MyDaC (Mysql) Query not have this parammetr..
well how i can use this commponents

djedai
Posts: 4
Joined: Fri 12 Oct 2007 17:51

Post by djedai » Sat 13 Oct 2007 08:22

Hey SOmeone Can Help me or all in this forum dead.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

wait...

Post by eduardosic » Sat 13 Oct 2007 20:35

djedai wrote:Hey SOmeone Can Help me or all in this forum dead.
wait.. be patient..

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 15 Oct 2007 07:10

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.

djedai
Posts: 4
Joined: Fri 12 Oct 2007 17:51

Post by djedai » Mon 15 Oct 2007 09:30

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;
this exemple for standart components Delphi 7

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

try this..

Post by eduardosic » Mon 15 Oct 2007 10:11

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;

djedai
Posts: 4
Joined: Fri 12 Oct 2007 17:51

Post by djedai » Mon 15 Oct 2007 10:52

OK All thx this Varian Work good. :)

Post Reply