Professional Documents
Culture Documents
Following are Two widely used Tools to connects database from Visual Basic Applications.
(i) Data Access Objects (DAO) - Data Controls
(ii) Active Data Object Data control (ADODC)
The Data Control Tool can be used to perform the following tasks:
1. Connect to a database.
2. Open a specified database Table.
3. Used to Search and Display information from the Table.
4. Add new records or update a Table.
6. Close the database.
Functions:
1. MoveFirst repositions the control to the first record.
5. AddNew A new record is added to the table. All fields are set to Null and this record is made the
current record.
6. Delete The current record is deleted from the table. This method must be immediately followed by one
of the Move methods because the current record is invalid after a Delete.
1. To make the connection between a MSFlex Grid and a Database, right click on the
MSFlex Grid control and select DataSource Name in the MSFlex Grid properties dialog
box.
2.From 'Property Pages' window, go to 'General' tab and go to 'Rows:' Textbox for
increase or decrease row cell.
3.Go to 'Column:' Textbox for increase or decrease Column cell. You can also adjust
Fixed Rows and Columns like it.
4.Just go to 'Fixed Rows:' Textbox and input row number and go to 'Fixed Cols:'
Textbox and input column number according to requirement.
Figure : Data Control With MS Flex Grid Control
3. To make the connection between a ADOC Control and a Database, right click on the ADO data
control and select the ADODC properties, the following dialog box will appear, the Select
Microsoft.Jet.OLEDB 4.0 in Use Connection String Field.
Select the following Information as show in below image:
i) In this dialog box, select the database file you have created, Press test connection to see
whether the connection is successful. If the connection is successful, click OK to return to
the ADODC property pages dialog box.
ii) At the ADODC property pages dialog box, click on the Recordsource tab and select 2-
adCmdTable under command type and select book as the table name, then click OK.
Finally you need to display the data in the DataGrid control. To accomplish this, go to the
properties window and set the DataSource property of the DataGrid to Adodc1. You can also
permit the user to add and edit your records by setting the AllowUpdate property to True. If
you set this property to false, the user cannot edit the records.
Step 2 : Select Microsoft DataGrid Control 6.0 by clicking the checkbox beside this item.
Step 3: You also need to select the Microsoft ADO data control so that you are able to
access the database.
Step 4: Now you should be able to see that the DataGrid control and the ADO data
control are added to the toolbox. The next step is to drag the DataGrid control and the
ADO data control into the form.
Step 5: Now you need to connect the database to the ADO data control. To do that,
right click on the ADO data control and select the ADODC properties, the following
dialog box will appear.
Next click on the Build button and the Data Link Properties dialog box will appear (as shown
below). In this dialog box, select the database file you have created, in my case, the file
name is books.mdb. Press test connection to see whether the connection is successful. If
the connection is successful, click OK to return to the ADODC property pages dialog box. At
the ADODC property pages dialog box, click on the Recordsource tab and select 2-
adCmdTable under command type and select book as the table name, then click OK.
Finally you need to display the data in the DataGrid control. To accomplish this, go to the
properties window and set the DataSource property of the DataGrid to Adodc1. You can also
permit the user to add and edit your records by setting the AllowUpdate property to True. If
you set this property to false, the user cannot edit the records.
MDI stand for Multiple Document Interface. MDI forms are the special type of
forms, especially used to handle multiple child forms.
A Multiple Document Interface is used to open many Forms at the same time.
Visual Basic applications can have only one MDI form (Parent Form), which
contains all the child forms.
A child form is an ordinary Form that has its Child property set True. Child form
are display within the internal area of MDI form at run time.
4. To form1 and Form2 set MDIChild property to True in Property of Form1 & Form 2
2. You can't place most controls on an MDI form. The only controls that can be placed
on the surface of the MDI form are Menus, Timer, CommonDialog, PictureBox,ToolBar,
and StatusBar.
Figure : MDI Form
The RichTextBox Control allows the user to enter and edit text, providing more
advanced formatting features than the conventional textbox control.
You can use different fonts for different text sections.
This control is loaded by selecting the Microsoft Rich Textbox Control 6.0 from
the Components dialog box.
How to Add the Microsoft Rich Textbox Control 6.0 control to your project?
1. Go to the Project menu and Click the Components.
2. Scroll down the list of components until you find "Microsoft Rich Textbox Control 6.0".
Select that checkbox and hit the OK button to add the control to your project.
Properties of the Rich Textbox Control:
1. LoadFile: It is used to Open a file and load the contents into the control.
2. SaveFile: It is used to Save the Rich Textbox contents into a file.
3. FileName: It is used to load the contents of a .txt or .rtf file into Rich Textbox
Control.
4. SelFontName: It is used to Set the font name for the selected text.
5. SelFontSize: It is used to Set the font size for the selected text.
6. SelFontColor: It is used to Set the font color for the selected text.