Delphi database programming tutorial
Question: Delphi beginners write free online tutorials for database programs, focus on ADO technology.
About this tutorial: It is a free online tutorial for Delphi database programming beginners, as well as a reference to people who want to know Delphi database programming art. Developers will learn how to design, develop and test database applications using Delphi and ADO technology. This tutorial focuses on the most common way to use ADO in the database application: connect the database with Tadoconnection, use tables and queries, process the database exception, create a report, and so on.
Prerequisites: The reader should have the application knowledge of the Windows operating system, a certain Delphi programming knowledge. New beginners can refer to the "Delphi Programming Beginner Guide" (I have time I will translate).
Chapter 1 Database Development Basis (with Delphi)
First Database Programming Tool Delphi
Many delphi beginners start Delphi programming with programs such as "MyNotepad", while other developers write multimedia and graphics applications, but they will realize that 90% of software today will be A certain manner is stored in a certain manner and affects.
One thing is no doubt: Delphi is effective and reliable in data management. The application developers who establish next-generation business software are attracted by Delphi: Use Delphi, we can develop software - ... Operate all types of desktop databases such as Paradox, DBASE, or MS Access. Using Delphi, we can also get C / S solutions.
Data Access with Delphi ... Just a few code (Data Access with delphi ... Just A Few Words)
Delphi comes with more than 40 pre-established database components, providing visual programming environments - including integrated code editor, database form wizard - Accelerating the creation of available database forms, data module designers ( Data Module Designer - Data Access Sharing for multiple tables. There are several Delphi-provided database-specific tools that can accelerate the generation of code and reduce programming.
The data access page of the component panel (Data Access) provides components for connecting the data source. Data Visual Components in Data Control Pages (Data Controls) are used to get data from the database or send data to the database. The components of the ADO page use ActiveX Data Objects technology to access database information through OLE DB. The component of the Interbase page is used to access the InterBase database directly.
Don't leave (Don't runaway)
Of course, database programming is not simple. In this course, we will try to bring you the latest technologies, problems and solutions for database programming with Delphi, and all secrets to us.
Before using Delphi's various data components and tools, we should first understand some concepts of the database design and try to design a simple database.
The second quarter creates a new database
Before we start interacting with Delphi and database, it is a good idea to understand the characteristics of a modern database. When you see the word the database, you will usually think of the various data stored in your computer - or even a .PAS file (source code for some Delphi unit) is also a database, other types of databases are a Word Documents or a simple .ini file. To access a .ini file, we usually use routines and techniques for classifying or unspeed files.
Establishing a modern database application requires us to consider data with relationships, the basic idea of relational models is that there is a list of tables (or relationships), which can operate and return to tables or so-called views. Simply put, the database is best described as a collection of associated data. A database can contain many different tables, a number of plaids - columns are specified in the field (Fields), is called ... Line (translator plus: or record) In order to fully understand the concept of database design and relationship model, we There is a need to learn an extra online tutorial - "Relational Database Design Basics" (Translator plus: translated in succession).
New ..... Database (New ... database)
Since this tutorial focus is introducing the Delphi database programming method of ADO / Access, now we will find out how to create a new .mdb database in MS Access. If you have never established a MS Access database, you can refer to the "MS Access Tutorials" (translator plus: translated by one).
Run MS Access, create a new empty database named AboutDelphi.mdb. Create three tables in the design window: Applications, Authors, and Types (Types). Let us look at the structure of these tables:
Applications contains fields that match the application description requirements: Name (Name), Description, Author (Author), Type (Type), Size (Size), Cost, Dateupl and Photo (Picture). Name (Name), Description, Author, Type field contains text (text) data, default is 50 characters. Scale Field (SIZE) is a numeric field (Single) type - stores the size of the file in KB. Cost (COST) field is a currency - if the application is shared software or business software. The dateupl field is a DATE / TIME value. Photo (Picture) is an OLE Object type with photos (arbitrary). Set the Name field as the main keyword.
The author's table (Authors) contains fields that match the app authors: Authorname, Email (Email), and web page (web). All fields contain character data (default is 50 characters). Set the author name field as the main keyword.
Type Table (Types) only contains a field: TypeName, which is also the primary keyword of the table. This table is used to store the type of application (graphics, multimedia, database ...). Now we only need to establish a relationship in relationship window, and the establishment of the database is completed.
The relationship should be "enforce reference integrity" tick before "Cascade Update Records".
December 19, 2002 22:38