Get the App
SLTechnology News&Howtos  ›  Development  › 

How to create an ADO.NET Connection object

Shulou Source: shulou.com Published: 2022-06-02 08:21:27 10月03日 Update

This article introduces the knowledge of "how to create ADO.NET Connection objects". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

By default, vc++ does not support ado objects. If you want to use the ado object in your program, you need to import the ado library file into the project using the # import command, as follows:

# import "c:\ Program Files\ Common Files\ System\ ado\ msado15.dll" no_namespace rename ("EOF", "adoEOF") rename ("BOF", "adoBOF")

The parameter no_namespace indicates a namespace that does not apply to ado. To avoid constant name conflicts, rename EOF to ADOBOF and BOF to ADOBOF. The ADO library contains three basic interfaces. That is, the _ ConnectPtr,_CommandPtr,_RecordSetPtr interface. They correspond to Connection objects, Command objects and RecordSet objects, respectively.

ADO.NET Connection object

The ADO.NET Connection object represents the connection to the data source. When accessing the database, first create an ADO.NET Connection object and use it to establish a connection to the database. You usually need to define a VConnection object in the header file.

_ ConnnetionPtr m_pConnection

The method to create a Connection object is as follows:

M_pConnection.CreateInstance ("ADODB.Connection")

ConnectionString attribute

ConnectionString= connection-> ConnectionString= "connection"

The time it takes for ConnectionTimeout to execute the command before terminating the attempt and generating an error, the default is 30sdepartment Mode, which specifies the permission of the Connection object to modify data. State returns the status of the Connection property, and the Open method is used to open a connection to the data source. Connection.Open (ConnectionString,UserId,Password,Options), the Close method (closes the connection to the database).

This is the end of "how to create ADO.NET Connection objects". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Object data database method content command property situation interface data source more knowledge utility learning next three code representative parameter name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MySQL NVidia Huawei Docker