Comprehensive development Practice of C + + Builder database

Source: Internet
Author: User
Tags config control label php language odbc table name access database phpmyadmin oracle database

A set of desktop systems originally developed in Access, Web Access using ASP programming, data Maintenance system using C++builder programming. Because access is a shared database of desktops, there are some problems with commonality and network development. Therefore, you need to migrate the system to a server-type database. Enable the system to maintain data through the desktop software, but also a large number of users through the Web page to see the data (results).

System initial software is: Windows98 second Edition, ACCESS97, c++builder4.0, c++builder5.0, MDAC (Microsoft Data Access Component 2.6 Chinese).

First, the attempt to migrate to Oracle

Install the Oracle 7.3 Desktop version on the machine, because the use is not skilled, therefore chooses the default installment, except chooses the language Simplified Chinese, other all chooses the default, all the way installs, does not have the question, restarts the system. Run NET Easy Config, configure the database alias you want, and then use SQL NET connection test, user name input system, password input manager, connect the server note, do not enter the server's address, but enter the alias just created, go in. Ok!

At this point, start testing ODBC and establish an ODBC data source. At this point, ODBC has two drivers for Oracle, one is Microsoft ODBC for Oracle and the other is Oracle 7.3, the company's own development drive. But how to choose the driver is not good, not the prompt Oracle driver is not installed, that is, a DLL file could not be found. If you say no, you can't do it.

Many tests are invalid ....

Check the Autoexec.bat file, which has the Oracle path. Then, where will the problem be? In a skeptical attitude, in the Msdos way to enter a path command, strange, there is no Oracle path! Open Autoexec.bat file a ponder, the path is not too long? Comment out all other directories in the path and reboot the system, Hey! The data source can be established, and all two drivers can work. Originally because the system installed the two versions of C++builder, and the software's directory is particularly deep, causing the PATH environment variable overflow, and in the Windows environment when the startup prompts we do not see, so did not find this problem. Now you know, readjust the Autoexec.bat file and keep a c++builder path. You'll have to remember that when you install C++builder, it's best to specify a directory yourself, which shortens the path. It's OK to say yes, no, it's OK.

With Oracle testing, it is found that migrating an Access database directly to an Oracle database has a problem with the migration of text fields (Text,memo), which is used, installed too complex, and requires too much machine configuration, and that the system needs more users to install. And the user level is uneven, so decided to switch to now in the free software industry more popular free database system MySQL.

Second, the experience of porting to MySQL

1. The installation of the system is relatively simple, if you think you do not have the ability to install the software, you can also download a software called Phptriad for Windows from the network, the software installed without any options, automatically installed MySQL. (In fact, the software also installed the Apache server, PHP language interpreter, which is exactly in line with the future of ASP's Web page into PHP; In addition, the software also installed a Web database maintenance tool phpMyAdmin, phpMyAdmin is extremely convenient for people who are not familiar with SQL language to manage databases. )

2. Then install MYODBC (that is, ODBC for MySQL, my version 2.5), note that when downloading the software, to distinguish between the 95 version or NT version. The installation is also very simple, all the way OK. OK, set up the data source work, fill in the IP address, the database name fills in Mymember (at this time the system provides the database), carries on the test, does not? Instead, use the system to automatically install the Sample-mysql data source connection, on the chain. Carefully check the configuration, no errors, why the system to do their own data source can be used, I do not do it? The establishment of their own deleted, the Sample-mysql renamed as Work, and then connect, hey, no! Haha, originally on the name, in the back of the work plus-mysql, and then connected, OK, the original MYODBC requirements of its data source name must end with MySQL! The data source is resolved, and the original Access database is migrated below.

Porting is easier, open an Access database, select the first table, select Save As/Export from the File menu, select Save As an external file or database, select "ODBC Database" in the "Save type" Drop-down menu in the pop-up dialog box, and eject an "export" dialog box, if you intend to rename the datasheet, you can now enter a new name, and then select OK, in the pop-up "Select Data Source" dialog box machine data source (machine), find the Work-mysql data source that you set up, click OK. The Access database is returned, and if the datasheet is large, the status bar will have an export progress, otherwise the export is complete.

After successful export, check the exported database through phpMyAdmin, and the structure and content are normal. It is to be noted that if you use the ID (AutoIncrement) field provided by Access in the datasheet, you need to manually modify the properties of the corresponding field in the target database (which is easy to implement in phpMyAdmin, find the field after the point "change", the last item in the field's properties "Extra" Drop-down menu, select Auto_increment, and then save. phpMyAdmin's interface is in English? In fact, as long as in the installation of phpMyAdmin directory apache\htdocs\phpmyadmin find config.inc.php files, search require, the quotation marks in the "english.inc.php" to "Chinese_" Gb.inc.php ", then to call the Web page of the phpMyAdmin, Xi hee, is not become Chinese? In fact, chinese_gb.inc.php is a filename, in the directory, you can also turn the interface into BIG5 code it.

3. Finally finished the transplant work, the following began to use C++builder programming. Use ADO to access the database. The steps are as follows: Select adotable in the ADO Control tab, place a ADOTable1 on the main window, and then click the "..." icon in the Left Object Viewer (objects Inspector), and select Use Connection String ", Dot" build ", in the" Provider "tab, select" Microsoft OLE DB Provider for ODBC Drivers ", point" next>> "button, in the" specify The source of data "Choose Use data Source name", from the dropdown menu, select the DataSource work-mysql, point "Test Connection", show the connection succeeded, OK, OK, return, in the Object Viewer table Name property Point Drop-down menu, select the data table you want. Then select DataSource from the Data Access Control tab, place a DataSource1 on the main window, pull down the dataset attribute point in the Object Viewer, select ADOTable1, the layout of the interface output below, and choose Data The dbedit in the Controls Control tab is placed as needed and the DataSource property is set to DataSource1, and the DataField property is set to the desired field name. So place a few fields, and then select "Dbnavigator" from the "Data Controls" control label on the window. And then the active property of ADOTable1 to True, ah, how some of the field shown into (MEMO), first regardless of him, run the program, enter some content, click Submit, why not? Some fields are shortened, try several times, found that the new input content can not exceed the original length, then the original is empty field will never be able to enter the content. What's going on? This usage is definitely fine, as it used to be on Access databases. Then, is the MySQL ODBC problem, exit C++builder, open the data source options carefully analysis, which the first vaaaa very much like. Check it, OK, rerun C++builder, run the program, everything OK. The original MySQL such free software, its ODBC options are many, is to adapt to all aspects of the need, unlike Microsoft or other databases, the default value can be used. This option may be to optimize some network applications, and the default value of the database field is always assumed to be the smallest state, resulting in thisProblem. This may also be a small drawback of free software.

Related Article

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.