Delphi-Kylix
  Home arrow Delphi-Kylix arrow Saving Files to a Database using Delphi: S...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Saving Files to a Database using Delphi: Saving Bitmaps to a Database
By: Danish Ahmed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2007-06-26

    Table of Contents:
  • Saving Files to a Database using Delphi: Saving Bitmaps to a Database
  • Create a new project
  • More components
  • Creating the application

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Saving Files to a Database using Delphi: Saving Bitmaps to a Database


    (Page 1 of 4 )

    In this series of articles I will discuss how to save and retrieve images and binary files to and from a database and recognize the format by reading the first four bytes of blob data. As usual I am using Borland Developer Studio 2006 (Delphi 2006) as the development platform and for the database server I will use MS SQL Server 2000. I intend to start from scratch and demonstrate how easily and quickly a database application can be created in Delphi by using its Data Access and Data-Aware components.

    In fact, you can create a simple but fully functional database application in Delphi without writing a single line of code! I will take you through a step by step demonstration of how to create a rudimentary database application in Delphi using data-aware components to save and retrieve bitmaps and other files to and from a database server and how to recognize the format of blob data by checking its first four bytes.

    The very first thing we need to do is create a blank database called TestDB in the remote MS SQL server. You can use any other existing database on any other server but you will have to make sure that it has a blob field in one of its tables where you can save the image. My TestDB contains just one table with three fields: a primary key field, a BLOB field and a text field for image description. This is the SQL script used to create the table:

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ImgTbl]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    drop table [dbo].[ImgTbl]

    GO

     

    CREATE TABLE [dbo].[ImgTbl] (

    [PKey] [int] IDENTITY (1, 1) NOT NULL ,

    [Image] [binary] (16) NULL ,

    [ImgDescription] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

    ) ON [PRIMARY]

    GO

    If you are using an older version of Delphi which requires you to access the database through BDE (Borland Database Engine) only, or for some reason you are using dbExpress (a simple and thin data-access layer providing connectivity to SQL database servers with the help of native drivers) to connect to the server, you have to make sure that a valid ODBC DSN(Data Source Name) has been created for the database and add that DSN in the dbExpress connections. If a valid DSN doesn't exist you can create one from the ODBC Administrator in the control panel.

    More Delphi-Kylix Articles
    More By Danish Ahmed


     

    DELPHI-KYLIX ARTICLES

    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...
    - Using the Client Dataset in File-Based Archi...
    - Demystifying the Client Dataset
    - Working with INI Files in Delphi
    - Creating Data Link (UDL) Files in Delphi
    - Looking at the Details for an Invoicing Appl...
    - Invoicing in Delphi: Show Me the Money
    - Saving Images and Binary Files to a Database...
    - Saving Files to a Database using Delphi: Sav...
    - Creating CF Applications and Integrating a S...
    - Using Try and Finally to Help Prevent Memory...
    - The Implementation of an FTP Server
    - FTP Server: The Theory


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway