Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 2 - 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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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
     
     
    ADVERTISEMENT


    Saving Files to a Database using Delphi: Saving Bitmaps to a Database - Create a new project


    (Page 2 of 4 )

    Once you have set up the database, fire up Delphi and create a new project. We will need to drop some VCL components on the form to start building our application. I will try to give a very brief overview to the various components we are going to use.

    Since our priority at the onset will be to ensure that our application can access the database server, we will start with the connection components. As is common with Delphi, there is more than one way to connect to the database from your application, but I will begin with a discussion of connecting through ADO components since that seems to be the preferred approach for most developers, including me.

    ADO can connect to the server using both OLE DB provider for ODBC drivers and OLE DB provider for SQL Server, so we don't have to worry about whether or not a valid DataSource name for the database has been created if we are using the latter. Now back to the ADO components we are going to use and a brief description of each. (Please note that I am leaving the components with their default names, that is, the first instance of TADOConnection is named ADOConnection1).

    TADOConnection The Connection component is necessary for establishing a connection to the database and interfacing the data store with the dataset. Further, the methods and properties of the Connection object can be useful in ensuring that all components access the database using one connection which is under proper control. You can specify which database you want to connect to by creating a connection string for the ADOConnection component.

    To create a connection string of an ADOConnection1 component, right click on the dropped component and select "Edit ConnectionString" or click the ellipsis button for the ConnectionString property in the Object Inspector. The Connection String Editor pops up; if you intend to use the DSN select the data source name from the drop-down box and make sure you select the correct Data Source Name. Enter username and password if necessary and specify the default catalog, and then click on "Test Connection" to make sure that you can connect to the database.

    However, creating a Data Source Name and then connecting to the server through it would not only be a lengthier process but unnecessary too since we can directly connect to the server with the OLE DB provider for MS SQL rather than depending on the ODBC driver to make the connection. To connect to the database server directly, select the provider tab in the Connection String Editor (Data Link Properties), then from the list of providers select "Microsoft OLE DB Provider for SQL server" and click next. Select the server name from the list of available servers; the database lookup box lists all databases available on the server. Select the one with which you want to work; in our case, that would be TestDB. Also make sure you allow for saving the password after you have entered one (or left it blank for the default). Finally click on the Test Connection; a message box informs you if the connection was successful.

    Once a valid ConnectionString has been provided, the ADOConnection1 object can be used to connect to the database by setting its Connected property to true or calling the "Open" method. Please note that if you don't want the login dialog displayed to the user every time you need to set the "LoginPrompt" property to false and must have provided the credentials in the connection string.

    More Delphi-Kylix Articles
    More By Danish Ahmed


     

    DELPHI-KYLIX ARTICLES

    - Loading an XML Document into the DOM
    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT