Best Windows Hosting

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Tuesday, 28 August 2012

How to use TADOTable in Delphi XE2?

Posted on 18:55 by Unknown
Following is the code snippet which will show you how to use TADOTable in Delphi XE2?

procedure TClass1.GetDataFromADOTable;
begin
  try
    if SetADOTable then
    begin
      if tADOTable.Locate('ColumnA;ColumnB', VarArrayOf([ValueA, ValueB]), [loPartialKey])  then
      begin
        VarX := tADOTable.FieldByName('ColumnX').AsInteger;
        VarY := tADOTable.FieldByName('ColumnY').AsInteger;
      end;
    end;
  except
    on E : Exception do
    begin
      ShowMessage('Error occured in function GetDataFromADOTable: ' + E.Message);
      exit;
    end;
  end;
end;

function TClass1.SetADOTable : boolean;
begin
  try
    tADOTable.Connection := ADOConnection;  //Connectin name
    tADOTable.TableName := 'myTableName';  //Table name
    tADOTable.Open;
    result := true;
  except
    on E : Exception do
    begin
      result := false;
      ShowMessage('Error occured in function SetADOTable: ' + E.Message);
      exit;
    end;
  end;
end;

Explanation: Lets discuss the SetADOTable function first. It assings TADOTable with connection name and table name and then it opens the table. Here all data is fetched in the ADOTable from myTableName table. Now come to the function GetDataFromADOTable. It checks if there is data in ADOTable, locates a pointer to a particular column/columns by using locate keyword. Then it fetches the values in VarX and VarY.
Email ThisBlogThis!Share to XShare to Facebook
Posted in Delphi | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • 13 Things to keep in mind before using DLL in Delphi
    Keep in mind the following tips when writing your DLL: 1. Make sure you use the proper calling convention (C or stdcall). 2. Know the correc...
  • How to use TADOTable in Delphi XE2?
    Following is the code snippet which will show you how to use TADOTable in Delphi XE2? procedure TClass1.GetDataFromADOTable; begin   try    ...
  • How to use FindComponent function in Delphi XE2?
    Following is the code snippet which will show you how to use FindComponent in Delphi XE2? procedure TClass1.UseFindComponent(FieldName : str...
  • Online Finance Degrees
    There is a great demand for professionals with profound knowledge of finance and accounting in most of the reputed banks and financial insti...
  • How to grab the recruiter’s attention with your resume?
    Did you know that the average recruiter spends about 8 to 10 seconds glancing at your resume before s/he moves on to the next? So, whether y...
  • 5 ways to handle workload at your workplace
    With bigger workloads, tighter deadlines and more pressure, the temptation to pack in as many tasks as possible is hard to resist. But juggl...
  • Online Marketing Degrees
    Because global competition has become so intense, it should come as no surprise that companies invest heavily in their marketing and promoti...
  • Oracle Streams: An Overview
    Oracle Streams enables information sharing. Each unit of shared information is called a message. The stream can propagate information within...
  • Frameset, Frame and IFrame Elements in HTML
    Frame Element With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and...
  • 5 Tips to enjoy your workplace
    Many people dislike getting up everyday and trudge to office. This is surprising, especially when we spend more than one-third of our day at...

Categories

  • AJAX
  • C++
  • CSS
  • Delphi
  • DOTNET
  • HTML
  • Javascript
  • jQuery
  • Management
  • Online Degrees
  • Oracle
  • Others
  • Phonegap
  • PHP
  • Unix
  • XML

Blog Archive

  • ▼  2012 (155)
    • ►  September (64)
    • ▼  August (11)
      • How important is grooming in professional life?
      • 7 Questions to Ask in Your Appraisal Meeting
      • 5 ways to handle workload at your workplace
      • Interview Tips: How to get prepared for an interview?
      • Phonegap on Blackberry: 2 Programming Tips
      • How to use FindComponent function in Delphi XE2?
      • How to use TADOTable in Delphi XE2?
      • How to use TADOQuery in Delphi XE2?
      • OnShortCut event of Delphi XE2 Forms
      • Phonegap: An amazing combination of HTML5, CSS3 an...
      • Delphi 2010, Delphi XE and XE2: A comparison of fe...
    • ►  July (4)
    • ►  June (3)
    • ►  May (25)
    • ►  April (48)
Powered by Blogger.

About Me

Unknown
View my complete profile