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--
Vb how to connect access database, believe that many people without experience at a loss, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Common ways to connect VB to an access database:
① Use ADO object to access database (Connection object, ODBC data source) by writing code;
② Use ADOData controls to quickly create database connections (DataLink files, use ODBC data source names, use connection strings);
③ Use Data Environment Designer to create database connections, first add environment references, and then find data sources to connect.
When operating these three connection methods, you will find repeated operations. Data control connection, ODBC data source connection and the use of string connection and direct use of ODBC data source connection, the difference is, directly use ODBC data source to set a good path, and then use the connection object connection;Data control is not a Connection object, there are controls, set a good path, directly connected to it.
Data environment designers and ADO objects both use connection connections. The difference is that in the data environment designer, the connection connection path is the same as the string connection step in the data control.
The following describes the VB connection access database these three methods detailed steps:
1, using ADOconnection object
First, you create an ADO reference, define the connection class, and instantiate the object.
The code is completed as follows:
DimobjCnAsNewConnection,objRsAsNewRecordset
objCn.ConnectionString="Provider=Microsoft.Jet.OLEDB.3.51;"&"DataSource="&App.Path&"\Example 01.mdb"
objCn.Open
2. Use ODBC data sources
First, open the ODBC data source on your computer and establish the relationship.
The procedure is as follows:
1) Open the ODBC data source on your computer
As shown in the following figure: 2) Click Add 3) Name 4) Establish relationship with database source 5) Connect with code
dimobjCnAsConnection
SetobjCn=NewConnection
objCn.Open"DSN= Instance 2DSN"
3, ADOData controls create connections
1) Right-click the data control and select ADODC Properties
5
2) Select one of the three connection resources.
Use dataLink file: click browse directly and find.udl file containing connection string
Use ODBC data source connection, click New to select user database, and then follow the same steps as in step 2.
Using Connection Strings: Click Make Test Connection 4 to create a database connection using Data Environment Designer
add reference
Right-click to create a connection, right-click on the property you want to connect, and then do the same as in using strings in the data control.
After reading the above, do you know how to connect access database in vb? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!
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.