Jumat, 16 Agustus 2024

Database Application Using Data Control (Very Old)

Lesson Requirement: NWIND.MDB, Microsoft Visual Studio 6, Data control in toolbox.

DatabaseName property to connect the data control to the database.
RecordSource property to select the table from the database file.

Data Binding

To bind other controls to the data control for the application to work.
DataSource property to bind a control to the data control name.
DataField property to bind the label to the correct field so that data in this field will appear on the conrol.

The following are some of the commands/methods that you can use to move/navigate the pointer around:

' Move to the first record
Data1.RecordSet.MoveFirst

' Move to the last record
Data1.RecordSet.MoveLast

' Move to the next record
Data1.RecordSet.MoveNext

' Move to the previous record
Data1.RecordSet.Previous

In the following example, you shall insert four command buttons event to browse through the database instead.
Private Sub cmdFirst_Click()
 Data1.Recordset.MoveFirst
End Sub

Private Sub cmdNext_Click()
 Data1.Recordset.MoveNext
End Sub

Private Sub cmdPrevious_Click()
 Data1.Recordset.MovePrevious
End Sub

Private Sub cmdLast_Click()
 Data1.Recordset.MoveLast
End Sub

You can also add, save and delete records using the following commands:

' Adds a new record
Data1.RecordSet.AddNew

' Updates and saves the new record
Data1.RecordSet.Update

' Deletes a current record
Data1.RecordSet.Delete

Bibliography:

Microsoft Visual Basic Step By Step;Microsoft Press
Enterprise Development with Visual Studio, UML, and MSF;John Erik Hansen, Carsten Thomsen;Apress
Visual Basic Developers Guide series;Sybex
Visual Basic series;Wrox
https://www.thevbprogrammer.com/index.asp
https://www.vbtutor.net/

visual basic 6, visual basic programming

Related Post

Tidak ada komentar:

Posting Komentar