Obtain MySQL data from the Web through Access _ MySQL

Source: Internet
Author: User
Tags microsoft access database
MySQL is currently the most popular network database. The reasons include: fast and free running in Linux and some of its platforms and Apache (a popular network server) A perfect combination of PHP and MySQL has an ODBC interface. If you are operating on a network server or MySQL server and want to associate data with a desktop application, use OD Access

MySQL is currently the most popular network database. The reasons include:
Fast running
Free
Can run on Linux and other platforms
Perfect Combination with Apache (a popular network server)
Perfect Combination with PHP
MySQL has an ODBC interface. If you are operating on a network server or MySQL server and want to associate data with a desktop application, using the ODBC interface is a good way. However, if you are not operating on the server, the port for accessing MySQL may be invalid. at this time, you can only seek other methods to operate on your data.

Problems
All the problems mentioned are for the client. For security reasons, client programs generally use a host to select network representatives, so as to avoid frequent logon to their systems on the network. Many hosts provide suitable conditions and MySQL, scalable FrontPage, CGI, and other site creation tools. They can also meet the matching problem between hardware and software. This unique host can even provide various tools to help you add or delete your MySQL database, but it is only in the basic MySQL storage format, this cannot directly read Access or other desktop programs.

The client program does not want to install MySQL on its own service machine. it can pass data through my program, as long as it runs MySQL on my machine. I can manually obtain data from the host storage. This process includes loading data to the database, transmitting data to Access through ODBC, and then sending the database content to the client. I don't mind doing this, but we should simplify unnecessary work rather than rely too much on manual operations.

Let me explain the above process. First, the host displays the data storage area on the web page, and obtains the database data through simple code and registration. the reason for registration is security considerations. Now, I use Microsoft's web browser ActiveX control to directly operate the Access database, which allows users to easily obtain MySQL data through the registration process by clicking the button, then pass the data to the corresponding table of the Access database. As long as the data is in the Access database, users can use ODBC or their usual method to transfer the data to the ERP system or other specialized systems.

Microsoft Access database
The Access database is quite simple. it consists of some data tables that list the data you want to add. In this section, the data table I used is named Sales_Data, which is composed of the purchase data on a virtual website. Similarly, this data table should be exactly the same as the MySQL data table on the host, regardless of its name or structure. In fact, we first need to generate A data table in Access (Figure A) and then transfer the data to MySQL on the local server through ODBC.

Figure



The Access application also opens the webpage control panel form. In my routine, the program registered on my server through PHP.

Figure B




The ActiveX control used is called WebBrowser1. the executed code is as follows:

Private Sub Form_Load ()
WebBrowser1.Navigate2 http: // 192.168.192.1 /~ Stew/mysql/
End Sub

Figure C




MySQL screen shot

The other part of the form includes two buttons. the first button (the control panel is displayed) displays the MySQL screen (C) using the following code ):

Private Sub LoadControlPanel_Click ()
WebBrowser1.Navigate2 http: // 192.168.192.1 /~ Stew/mysql/mysql_dump.php
End Sub

The second button gets data, which is the main part of the code.
Next, you will see a drop-down list of the Access database, and the list contains data. In this example, the list name is Sales_Data.

In addition, the check box allows you to select whether to delete the old data before adding the data. you can perform some useful operations here, but these operations must be legal.

Finally, the two text interfaces contain the unit name and MySQL database name.

Summary
The above is the whole process. You must use network interfaces to run database queries on the host. When the MySQL storage is displayed in the form browser (D), click the Get Data button to get the data and store it in the Access data table. The program also checks whether the data storage is based on MySQL in a certain format, and ensures that the database and data table are correct. If these rules are met, the INSERT command in the program will be executed to add the data to the target data table. a message dialog box will pop up to display this process. If an error occurs, the system returns to the form. Listing A contains the complete code.

Figure D




MySQL screen dump

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.