Five examples of VB6.0 database development--a summary of the list

Source: Internet
Author: User
Tags odbc

Instance One: System Login dialog box

Design Analysis: Database management System Login dialog Two basic methods: database to establish a data table to save the system user login information; a database management system that supports secure authentication, which defines a system user as a database user.

Technical essentials: 1, Enter, Cancel

2. ADO Connection Object

3. ADO Recordset object (Related attributes: Active connection, Eof, Field; method: Open; Fields collection)

4. Define the Function procedure yourself

Operation procedure: 1, the visual Data Manager creates the database;

2, design window;

3, the establishment of ADO object reference, access to the database;

4, write function code: cancel Login function;

5, write username, password verification process;

6. Determine the button click event procedure;

7, save the common process, test execution.

Example two: ADO Access data source

Design Analysis: 1. There are two ways to update a data source using ADO. the Updata and Updatabatch methods in the Recordset object. Exclusive mode, and other users to access the data at the same time; command object run SQL Data update commands.

2. Technical essentials: Recordset record lock type, CursorLocation, browsing record in Recordset, ODBC data source type

Manipulating project:1, creating ODBC data sources

2. Design Record Browsing window

3. Establishing an ADO reference

4. Write function code: Declare part, load section (connect database, retrieve data, display record AbsolutePosition RecordCount), run Data update process, "previous record" "Next Record" button, unload event

Connection--retrieval--operation

Example three: Using data binding to access data

Concept: Data binding

Design analysis: Access to database mode: 1, using ADO object 2, using ADO Data Control 3, Data Environment Designer

Technical essentials: Adodata control basic structure, Adodata control property settings (general, authentication, record source, color, font)

Data-bound control internal controls (Image, ComboBox, CheckBox, ListBox, Textbox, Pictureboxlabel)

ActiveX controls (RichTextBox, Microsoft Chart, Datatimepicker, ImageCombo, MonthView, DataList, Dtacombo, Datagrid, Microsoftherarchical FlexGrid)

Related Properties Datasource, DataMember (DataSet), DataField, DataFormat

Data Environment Designer can join multiple different database connections

How to: Design application windows, write functional code, save project

Example four: Paging Display records

Features: Record paging using the paging feature of the recordset

Use the DataGrid control's data binding feature to display paginated data records

Design analysis: Use the PageSize property of a recordset to set or return the number of record bars that can be included in a record.

Two methods display the record page data: Using the DataGrid control, you cannot bind a paginated recordset directly to a DataGrid control, you can copy the data from the current record page to a new recordset, and then bind it to a DataGrid control; using the MSFlexGrid control, The data is displayed through the Textmatrix property at execution time.

Example five: Data query

Feature: Use the ADO Command object to create a parameter query to query the database.

Using the MSFlexGrid control to display query results

Design analysis: There are several ways to implement database queries: 1. Construct the SQL SELECT statement using query parameters, and then run using the ADO command or the Resordset object. 2. Create a parameter query using the ADO Command object. 3. Run the SELECT statement to get the database data, store it in the Recordset object, and then find the matching record in the Find method that runs the Recordset object, or set the Filter property of the Recordset object to filter the records that match the criteria.

Technical essentials: MSFlexGrid Control Data entry and removal (AddItem, RemoveItem, clear);

Use the Command object to create a parameter query, divided into the following steps:

1. Create Command Object objcommandtext= "SELECT * from System user Where username like?"

2. Use the Creatparameter method of the Command object to create the Parameter object and then add it to the Parameters collection of the Command object.

Dim Parm as parameter

Set Parm=objcmd. Creatparameter ("username", advarchar,adparaminput,10)

Objcmd.parameters.append Parm

3. Set the value of the parameter, objCMD ("username") = "admin"

4. Execute method to run command completes query

Five examples of VB6.0 database development--a summary of the list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.