Cheap Hosting Domain Names

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

Wednesday, 12 September 2012

How to use SaveToFile and LoadFromFile in Delphi XE2?

Posted on 22:07 by Unknown

The data retrieved via an ADO dataset component can be saved to a file for later retrieval on the same or a different computer. Save the data to a file using the SaveToFile method. Retrieve the data from file using the LoadFromFile method. The data is saved in one of two proprietary formats: ADTG and XML. Indicate which of these two formats to use for the save file with one of the TPersistFormat constants pfADTG or pfXML in the Format parameter of the SaveToFile method.

procedure TForm1.SaveBtnClick(Sender: TObject);
begin
  if (FileExists('c:\SaveFile')) then begin
    DeleteFile('c:\SaveFile');
    StatusBar1.Panels[0].Text := 'Save file deleted!';
  end;
  ADODataSet1.SaveToFile('c:\SaveFile', pfADTG);
end;

procedure TForm1.LoadBtnClick(Sender: TObject);
begin
  if (FileExists('c:\SaveFile')) then
    ADODataSet2.LoadFromFile('c:\SaveFile')
  else
    StatusBar1.Panels[0].Text := 'Save file does not exist!';
end;

Explanation: In the example above, the first procedure saves the dataset retrieved by the TADODataSet component ADODataSet1 to a file. The target file is an ADTG file named SaveFile, saved to a local drive. The second procedure loads this saved file into the TADODataSet component ADODataSet2.

The saving and loading dataset components need not be on the same form as above, in the same application, or even on the same computer. This allows for the briefcase-style transfer of data from one computer to another.

On calling the LoadFromFile method, the dataset component is automatically activated.

If the file specified in the FileName parameter of the SaveToFile method already exists, an EOleException exception is raised. Similarly, if the file specified in the FileName parameter of LoadFromFile does not exist, an EOleException exception is raised.
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

  • Online Economics Degrees
    Economists research and analyze economics, or the way people choose to use their resources to produce goods and services. Economists typical...
  • Online DBA (Database Administrator) Degrees
    Database managers keep vital information organized.  With a database technology degree, you may find yourself organizing customer informatio...
  • Online Advertising Degrees
    The objective of any business firm is to market and sell its products or services profitably. In small firms, the owner or chief executive o...
  • Online Photography Degrees
    For those crave autonomy, flexibility, and, above all, creativity, a career in photography may seem ideal. If you have an artistic eye, tech...
  • Online BCA Degrees
    The boom in the IT industry has opened up plenty of job opportunities for computer professionals. As a result, computer application courses ...
  • Online Professional Degrees
    Going back to get more education can be a difficult, time consuming and sometimes impossible proposition. But with new advances in virtual t...
  • Online Pharmacy Degrees
    Filling prescriptions is only one job that pharmacists perform each day. Taking inventory, making sure people are taking the right medicatio...
  • Online MA Degrees
    A Master of Arts (MA) is a postgraduate academic degree that is typically awarded in Humanities, Fine Art, Theology or Social Sciences. The ...
  • Online Social Science Degrees
    Social science covers a broad range of fields: behavioral science, history, economics, geography, political science, women''s studie...
  • Online Human Resource (HR) Degrees
    In today's economy, the quality of a company''s personnel can mean the difference between a slot on the Fortune 500 and a trip t...

Categories

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

Blog Archive

  • ▼  2012 (180)
    • ▼  September (89)
      • Online Economics Degrees
      • Online Project Management Degrees
      • Online Photography Degrees
      • Online Pharmacy Degrees
      • Online Radiology Degrees
      • Online Nutrition Degrees
      • Online Mathematics Degrees
      • Online English Degrees
      • Online Criminology Degrees
      • Online Counseling Degrees
      • Online Animation Degrees
      • Online Information Technology Degrees
      • Online Elementary Education Degrees
      • Online Adult Education Degrees
      • Online Computer Science Degrees
      • Online Aviation Degrees
      • Online BCA Degrees
      • Online Culinary Degrees
      • Online Religion Degrees
      • Online Dental Degrees
      • Online Criminal Justice Degrees
      • Online Communication Degrees
      • Online Philosophy Degrees
      • Online Political Science Degrees
      • Online Teaching Degrees
      • Online Music Degrees
      • Online Accredited Degrees
      • Online Advertising Degrees
      • Online Finance Degrees
      • Online Marketing Degrees
      • Online Forensic Science Degrees
      • Online DBA (Database Administrator) Degrees
      • Online Biology Degrees
      • Online Geography Degrees
      • Online History Degrees
      • Online Art Degrees
      • Online Sports Degrees
      • Online Agriculture Degrees
      • Online Library Science Degrees
      • Online Environmental Science Degrees
      • Online Business Degrees
      • Online Physical Education Degrees
      • Online Science Degrees
      • 5 Tips to enjoy your workplace
      • 5 E-mail Etiquette You Must Know
      • How to grab the recruiter’s attention with your re...
      • 30 Facts About Google Adsense You Must Know
      • Working of the JSP Container
      • List of 70 basic commands of UNIX
      • 13 Point comparison between SQL and PLSQL
      • 10 Rules of Operator Overloading in C++
      • 6 Point comparison between Apache and IIS Web Servers
      • 5 Qualities of a good manager
      • Never try to fake your Resume / CV
      • How to write a cover letter of your resume?
      • The crucial first 5 minutes of an Interview
      • Rejected in an Interview? Don't Lose Your Heart
      • 6 FAQ’s in an interview
      • 5 ways to get into the good books of the boss
      • 5 Reasons to Quit Your Job
      • Online Web Designing Degrees
      • Online BBA Degrees
      • Online MA Degrees
      • Online BA Degrees
      • Online Human Resource (HR) Degrees
      • Online Graduate Degrees
      • Online Master Degrees
      • Online Fashion Design Degrees
      • Online Bachelor Degrees
      • Onlin PhD Degrees
      • Online Nursing Degrees
      • Online MBA Degrees
      • Online Doctorate Degrees
      • Online Psychology Degrees
      • Online Social Science Degrees
      • Online Law Degrees
      • Online Accounting Degrees
      • Online Medical Degrees
      • Online Engineering Degrees
      • Online Professional Degrees
      • 3 Things to keep in mind while you quit your job
      • Planning a job change? Tips to negotiate salary
      • How to use SaveToFile and LoadFromFile in Delphi XE2?
      • How to use TADODataset, TDatasource and TDBGrid in...
      • Embarcadero HTML5 Builder Features List
      • 5 ways to handle an interview over a video call
      • List of 8 job interview goof-ups
      • Anatomy of the commonly asked interview question “...
      • Use Social Networking Sites To Groom Your Career
    • ►  August (11)
    • ►  July (4)
    • ►  June (3)
    • ►  May (25)
    • ►  April (48)
Powered by Blogger.

About Me

Unknown
View my complete profile