In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about how to access the database through the ADO control, many people may not know much about it. In order to make you understand better, the editor summarizes the following content for you. I hope you can get something according to this article.
Take the Microsoft Office Access database as an example to explain how to access the database through the ADO control.
This method basically does not need to write code, can complete the access to the database, very convenient.
1. Create the database student.mdb in Access, and add the table stu_info, as shown below:
The field names here are in Chinese, just for the convenience of teaching, so it is recommended to use English field names in practical work.
2. Set up a MFC dialog box project AdoCtrl.
3. Add the following two ADO controls to the dialog interface editor:
ADO Data control, used to establish a database connection.
An ADO DataGrid control that represents a result recordset.
In the dialog editor-- > right-click menu-- > Select Insert ActiveX Control-- > select Microsoft ADO Data Control,Version 6.0 OK-> click OK in the dialog box that appears, so that the ADO Data control IDC_ADODC1 is added to the dialog box.
Similarly, select Microsoft DataGrid Control,Version 6. 0 to add to the dialog box. So the DataGrid control IDC_DATAGRID1 is added to the dialog box.
4. Set the properties of the connection control in the dialog box
Set the properties of the ADO Data control: select the Control page in the properties dialog box, and you can make three choices
Select the Use Connection String option, click the Build button, and select the Microsoft Jet 4.0 OLEDB Provider provider in the dialog box that appears. Click next to select the name of the Access database file you just created, student.mdb. Point to test the connection, should be able to connect to the database through. Open the property settings of the ADO Data control again, select the RecordeSource page, select 2-adCmdTable in Command Type, and select the stu_ info table in Table Or StoredProcedure Name.
Set the properties of the DataGrid control: select the Control page in the properties dialog box, select the Allow AddNew and Allow Delete check boxes, select the All page, and set the DataSource parameter to the ID that connects the control, that is, IDC_ADODC1.
5. Run the program
You will be able to connect to the database in a dialog box and display the data in the table in the Grid control.
(note: except for three kinds of hanging pictures above, all of them are reproduced.)
Here is how to connect to MySQL with the ADO control:
Add the name of the data source and click NEW
Select the data source type and click next
Choose to install the driver for the data source, which can be selected according to the type of database used. I am using MySQL here.
Type the name of the data source you want to save. I'm using the name of the table that has been created in the database.
After clicking to browse
Click finish, pop up, enter the user name, password, select the established database name, click Test, if the connection is successful, a small window pops up,
If the specific programming is to be implemented in accordance with ADO, the data can be stored in the database.
After reading the above, do you have any further understanding of how to access the database through the ADO control? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.