0% found this document useful (0 votes)
2 views

Advanced Visual Basic unit -4(vt)

The document provides an overview of database concepts and operations in Visual Basic 6 (VB6), including methods for accessing databases such as DAO, RDO, and ADO. It details the use of data controls to connect forms to databases, the properties and navigation of recordsets, and steps for creating and managing databases. Additionally, it outlines basic operations like adding, deleting, and updating records within a database.

Uploaded by

vanshthakral2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Advanced Visual Basic unit -4(vt)

The document provides an overview of database concepts and operations in Visual Basic 6 (VB6), including methods for accessing databases such as DAO, RDO, and ADO. It details the use of data controls to connect forms to databases, the properties and navigation of recordsets, and steps for creating and managing databases. Additionally, it outlines basic operations like adding, deleting, and updating records within a database.

Uploaded by

vanshthakral2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Advanced Visual Basic

Unit -4

A database is a collection of one or more tables

Database accessing methods are as follows:


Jet Engine, ODBC (Open Database Connectivity), ISAM (Index Sequential Access Method)

 Jet Engine – Access

 ODBC – Connectivity

 ISAM – Indexing

✅ Data Controls in VB6

Used to connect VB forms to databases for data viewing and editing.

📘 Data Bound Controls

 TextBox – Edit field

 Label – Display field

 DataGrid – Show table

 DBCombo – Dropdown list

 DBList – List box

 Image – Show image

 CheckBox – Yes/No

 OptionButton – One choice

 DataCombo – ADO dropdown

🔷 Combined Question Breakdown

Question 1:

"How can we use DAO data control? Explain various methods to access database in VB6."

This includes the following topics:

 Connect with database using DAO in VB6 using the data control ✅

 Accessing Data Through RecordSet Objects ✅

 Important properties of recordset in VB6 ✅

 Navigating the recordset in VB6 ✅


 Navigation through recordset ✅

 Moving database using recordset ✅

Question 2:

"How can you connect database with DAO data control in VB6?"
✅ This is included in Question 1, so no need to repeat — answer is already part of Question 1.

🌐 1. Using DAO Data Control in VB6

connect and interact with databases like Microsoft Access.

📌 Steps to Use DAO Data Control:/ "Accessing database using DAO Data Control"/ Connecting to
database using DAO Data Control

✅ Steps to Use DAO Data Control in VB6 (Short)

1. Add Data Control – Drag it to the form.

2. Set Properties – Set DatabaseName and RecordSource.

3. Bind Controls – Set DataSource and DataField.

The 4 most important properties of the DAO Data Control in VB6 are: DatabaseName,
RecordSource, Connect, Recordset

📁 2. Accessing Data Using Recordset Object

Set rs = OpenDatabase("path").OpenRecordset("SELECT * FROM Table", Dynaset)

Close:

rs.Close

db.Close

Recordset Types:

1. Table: Editable
2. Dynaset: Updatable
3. Snapshot: Read-only
4. Forward-Only: Unidirectional
5. Dynamic: Editable

Here are the four most important properties of Recordset in VB6:

1. EOF
1. Usage: Data1.Recordset.EOF
2. BOF
1. Usage: Data1.Recordset.BOF
3. RecordCount
1. Usage: Data1.Recordset.RecordCount
4. Fields
1. Usage: Data1.Recordset.Fields("FieldName")

Navigating Recordset:

 MoveFirst: Moves to first record.

 MoveLast: Moves to last record.

 MoveNext: Moves to next record.

 MovePrevious: Moves to previous record.

 Move n: Moves to specific record.

Example:

Data1.Recordset.MoveFirst ' First record

Data1.Recordset.MoveNext ' Next record

Data1.Recordset.AddNew ' Add new record

Data1.Recordset.Delete ' Delete record

Data1.Recordset.Update ' Update record

Here’s a very short guide to modifying a database using Recordset in VB6:

1. Add Record:

2. Data1.Recordset.AddNew

3. Data1.Recordset!FieldName = "Value"

4. Data1.Recordset.Update

5. Update Record:

6. Data1.Recordset.Edit

7. Data1.Recordset!FieldName = "NewValue"

8. Data1.Recordset.Update

9. Delete Record:

10. Data1.Recordset.Delete

11. Data1.Recordset.Update

🔹 RDO (Remote Data Objects) – Quick Notes


 access databases via ODBC (faster than DAO).

 MSRDC = Remote Data Control

🔹 Steps to Use RDO

1. Register ODBC Source

o Control Panel → Admin Tools → Data Sources (ODBC)

o Add → Select MS Access Driver (.mdb) → Choose DB → Name it (e.g., Demo).

2. Add MSRDC Control

o Project → Components → Microsoft Remote Data Control 6.0 → OK

o Place MSRDC on form.

3. Set MSRDC Properties

o DataSourceName: Select Demo

o SQL: e.g., SELECT * FROM Author

🔹 Recordset Navigation

RDO1.Recordset.MoveFirst

RDO1.Recordset.MoveLast

RDO1.Recordset.MoveNext

RDO1.Recordset.MovePrevious

Use TextBox with DataSource = RDO1 and DataField = "FieldName" to display data.

🔹 What is ADO?

 Latest Microsoft data access object.

 Combines features of DAO and RDO.

 Supports local, network, and web connections.

🔹 Uses of ADO Data Control (ADODC)

ADO Data Control Functions (Short):

 Connects to DB

 Opens table

 edits in controls
 Adds/updates records

 Handles errors

 Closes DB

🔹 Steps to Use ADO in VB

1. Project → Components → ADO Data Control 6.0 (OLEDB).

2. Place ADODC on form.

3. Set ConnectionString → Use Jet 4.0 → Select .mdb file.

4. Set RecordSource → Choose table (e.g., Authors).

🔹 Connect ADODC to TextBox

 Use DataSource = ADODC

 Use DataField = Table Field (e.g., Name, ID)

🔹 Recordset Navigation

adodc1.Recordset.MoveFirst ' First Record

adodc1.Recordset.MoveLast ' Last Record

adodc1.Recordset.MoveNext ' Next Record

adodc1.Recordset.MovePrevious ' Previous Record

🔹 Other Methods

adodc1.Recordset.AddNew ' Add new record

adodc1.Recordset.Delete ' Delete record

adodc1.Recordset.Update ' Save changes

DAO: Local
RDO: ODBC
ADO: Flexible(best)

Sure! Here's a slightly shorter version of the notes on database operations in VB6:

✅ Creating the Database

1. VDM → New → MS Access 7 MDB → Save as db.mdb.


2. Right-click → Properties → New Table → Add fields → Save table.

✅ Entering Data

1. Right-click table → Open → add data → Update.

✅ Basic Operations

 Add: Data1.Recordset.AddNew

 Delete: Data1.Recordset.Delete, MoveNext

 Update: Data1.UpdateRecord

 Refresh: Data1.Refresh

✅ Viewing the Database

 Use MS Access or bound controls in VB.

 VDM → Data Form Designer.

You might also like