Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Programming language Visual Basic 6 (Chapter 16 - Programming with ADO (Part I))

ADO Data Control

Visual Basic 6 gives us the choice of technique when programming with database, or use  DAO  as in the previous two articles, or are using  ADO (ActiveX Data Objects) .

The main difference between ADO and the ADO DAO allows us to work with any type of data sources (data sources), not necessarily the Access database or ODBC. Data sources can be a list of email addresses, or a text string, where each row is a record consisting of fields separated by commas ( comma separated values ).

If the DAO is used directly in the name of the Database MSAccess ADO us  connected (connect)  a database through a Connection by specifying a  Connection String . In the Connection String Database Provider  (such as Jet, ISAM, Oracle, SQLServer, etc. ..), Database name,  username / password logon to a database. etc. Then we can  retrieve (extract)  the recordsets and update the records using the  SQL command  used on the tables or  stored procedures  inside the database.

Programming language Visual Basic 6 (Chapter 15 - Programming with technical DAO)

Reference Dao

In this article we will learn basic programming with MS Access database through DAO techniques without the use of the  Control  Data  as in the previous post. I will need some DAO Objects in the library, so if you open a new VB6 project, use the Command Menu  Project | References ...  to select the Microsoft DAO Object Library 3:51  by clicking the checkbox to the left like in the picture below here. (One way to remember the name of this object is to remember the sentence  "He's DAO 35 goats" ).


Programming language Visual Basic 6 (Chapter 14 - Using Data Control)

Control Data

From VB5, Visual Basic for a programmer to control access to databases, it's just a simple name is  Data. As we know, there is a database when you buy bundled Microsoft VB6 - that is  Jet Database Engine .Jet Database Engine is the  "engine room"  of the MS Access Database Management System.

Until VB5, Microsoft gives us three main techniques:

  • DAO (Data Access Objects) : DAO is esoteric techniques of Microsoft, just to use the Jet Database Engine. It is easy to use, performance and convenience, but are limited within MS Access. Nevertheless, it is so prevalent because there are practical benefits.
  • ODBC (Open Database Connectivity) : ODBC is designed to let users connect with all sorts of databases that use only a single method. This put the burden for the programmer, to just learn a single programming techniques that can work with any database of any kind. Especially if you later need to change the type of database, such as upgrading from Access to SQLServer instance, the alteration of very little coding. When using ODBC with DAO, you can connect to Access Database with other databases. There is a disadvantage of ODBC is that it is confusing.
  • RDO (Remote Data Object) : One of the main reasons for RDO is designed to solve the difficult problem of ODBC. How to program with simple DAO RDO, but actually it should allow users to use ODBC connections to multiple databases. However, the RDO is not very prevalent.

Programming language Visual Basic 6 (Chapter 13 - Database (Database))

Table, Record và Field

Speaking to the database, we immediately think of SQLServer, Access or Oracle. Etc., where contains a lot of data so that we can store or retrieve them conveniently and quickly. Most programs we write will have access to databases, and we use it as a tool to work with a lot of data while focusing on the programming interface to the user (users).

So we need a basic knowledge about the architecture of the database to understand the reasons why we design or access it in certain ways.

We will use biblio.mdb Access Database, located at C: Program FilesMicrosoft VisualStudioVB98 iblio.mdb to illustrate the concepts need to know about databases.
In this database has 4 tables: Authors (author), Publishers (publishers), Titles (section)vaTitle Author.


Programming language Visual Basic 6 (Chapter 12 - Using Graphics (Part III))

Graphics Methods

While Graphical Controls like Shape, Line gives us the design drawing at the  Graphics Methods  to draw these things at run-time. We can also put individual spots (pixels) or copy a Picture from one place to another.

Just a bit of experience you can do animation (animation) or create amazing visual effects without having to touch the  Windows API (Application Programming Interface)  to use the  BitBlt function .

Method PaintPicture

PaintPicture method  allows you to quickly copy a block of data graphics, literally, a region in a graphic image on a form, PictureBox, or Printer to another place. For example, you copy an image from one place to another in the form, or from form / PictureBox to the Printer Object for a while after you print it out.

Programming language Visual Basic 6 (Chapter 12 - Using Graphics (Part II))

Print screen

VB6 is our method for printing Print directly on the Form, PictureBox, or Printer. Threetypes of control is seen as the canvases that the artist painted.

Please start a new VB6 program. Set up a PictureBox named Picture1 and form a button with the name CmdPrintTenLines Caption  Print Ten Lines . DoubleClick on this button and write code below:

Private Sub CmdPrintTenLines_Click() 
   Dim i As Integer 
   ' String variable used for display
   Dim strLine As String 
   ' Write 10 lines, one under the other
   For i = 1 To 10 
      strLine = "This is line " & CStr(i) 
      Me.Print strLine  ' Print on Form
      Picture1.Print strLine  ' Print on Picture1
   Next 
End Sub