Here is just a simple VB applet example, but it contains these keywords: VB6.0, ADO, Access
Environment: visual basic 6.0 Enterprise Edition (not the streamlined version, otherwise it will lack necessary controls)
Database: Access database, the database is xs.mbd, the built-in table is xj
Result: VB uses ADO to connect to the access database, queries all the data in the xj table, and then outputs the query results to the window in a loop.
Code:
Private Sub Form_Click()Dim db As New ADODB.Connection, RS As New ADODB.Recordset 'ADO connection object and record set Dim strSQL As String 'SQL string db.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data source =" & App.Path & "/xs.mdb" 'Database connection db.Open 'Open the database strSQL = "select * from xj" 'SQL string RS.Open strSQL, db, 3, 1 'Query the data table Do While Not RS.EOF 'Loop to output the query results Print RS! Name; RS! Gender; RS! Class; RS! Date of birth' Print the output results in the window RS.MoveNext 'Move record down LoopRS.Close 'Close the record set Set RS = NothingEnd Sub
The above is the entire content of this article, I hope you all like it.