VS2017,MFC使用ADO方法连接oracle数据库

小粽子穿花衣 2020-05-31 07:39:16
我看到书上是如图一这么写的,但是他是使用microsoft sql server 2014写的数据库,我是用的oracle11g,我不太明白这里我应该怎么改一下?可不可以顺便讲解一下这两句话的意思?
以及我是重新创建了一个ADO.h和ADO.cpp文件,写的连接功能,请问如果我创建一个窗体的话还是需要在view.cpp文件里创建嘛?然后在view.cpp里调用ADO.h?
图二和图三是我创建的ADO.h和ADO.cpp
...全文
344 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
an_bachelor 2020-06-02
  • 打赏
  • 举报
回复
Connecting to an Oracle Database To connect to an Oracle Database using OraOLEDB, the OLE DB connection string must be as follows: "Provider=OraOLEDB.Oracle;User ID=user;Password=pwd;Data Source=constr;" When connecting to a remote database, Data Source must be set to the correct net service name which is the alias in the tnsnames.ora file. For more information, refer to Oracle Database Net Services Administrator's Guide. OraOLEDB-Specific Connection String Attributes OraOLEDB offers provider-specific connection string attributes, which are set in the same way as the Provider and User ID are set. The provider-specific connection string attributes are: CacheType - specifies the type of cache used to store the rowset data on the client. See "OraOLEDB-Specific Connection String Attributes for Rowsets". ChunkSize - specifies the size of LONG or LONG RAW column data stored in the provider's cache. See "OraOLEDB-Specific Connection String Attributes for Rowsets". DistribTX - enables or disables distributed transaction enlistment capability. See "Distributed Transactions". FetchSize - specifies the size of the fetch array in rows. See "OraOLEDB-Specific Connection String Attributes for Rowsets". OLEDB.NET - enables or disables compatibility with OLEDB.NET Data Provider. See "OLEDB.NET Data Provider Compatibility". OSAuthent - specifies whether operating system authentication will be used when connecting to an Oracle Database. See "Operating System Authentication". PLSQLRSet - enables or disables the return of a rowset from PL/SQL stored procedures. See "OraOLEDB Custom Properties for Commands". PwdChgDlg - enables or disables displaying the password change dialog box when the password expires. See "Password Expiration". UseSessionFormat - specifies whether to use the default NLS session formats or let OraOLEDB override some of these formats for the duration of the session. Valid values are 0 (FALSE) and 1 (TRUE). The default is FALSE which lets OraOLEDB override some of the default NLS session formats. If the value is TRUE, OraOLEDB uses the default NLS session formats. Note that this connection attribute does not appear under the \\HKEY_LOCAL_ MACHINE\SOFTWARE\ORACLE\KEY_HOMENAME\OLEDB registry key. VCharNull - enables or disables the NULL termination of VARCHAR2 OUT parameters from stored procedures. SPPrmDefVal - specifies whether to use the default value or a NULL value if the application has not specified a stored procedure parameter value. NDataType - specifies whether any of the parameters bound to the command are of N data types, which include NCHAR, NVARCHAR2, or NCLOB. See "NDatatype". Note that this connection attribute does not appear under the \\HKEY_LOCAL_ MACHINE\SOFTWARE\ORACLE\KEY_HOMENAME\OLEDB registry key. SPPrmsLOB - specifies whether one or more parameters bound to the stored procedures are of LOB data type, which include CLOB, BLOB, or NCLOB. See "SPPrmsLOB". Note that this connection attribute does not appear under the \\HKEY_LOCAL_ MACHINE\SOFTWARE\ORACLE\KEY_HOMENAME\OLEDB registry key. StmtCacheSize – specifies the maximum number of statements that can be cached. See "Statement Caching". MetaDataCacheSize - specifies the maximum number of SELECT statements for which the metadata can be cached. See "Metadata Caching". DeferUpdChk - specifies whether or not to defer the updateability check to support updating read-only disconnected rowsets. See DeferUpdChk under "OraOLEDB-Specific Connection String Attributes for Rowsets". DBNotifications - specifies whether or not to subscribe to the high availability events. See "Enhanced Failover Capability". DBNotificationPort - specifies the port number, which is opened to listen to the Database notifications. See "Enhanced Failover Capability". Default Attribute Values The default values for these attributes are located under the \\HKEY_LOCAL_ MACHINE\SOFTWARE\ORACLE\KEY_HOMENAME\OLEDB registry key, where KEY_HOMENAME is the Oracle home. The registry default values are read by OraOLEDB from the registry when the provider is loaded into memory. If Oracle-specific connection string attributes are not provided at connection time, then the default registry values are used. However, if the attributes are provided, then these new values override the default registry values. These attributes can be set by setting the DBPROP_INIT_PROVIDERSTRING property, provided in the DBPROPSET_DBINIT property set. For example: "FetchSize=100;CacheType=Memory;OSAuthent=0;PLSQLRSet=1;StmtCacheSize=10;" Distributed Transactions The DistribTX attribute specifies whether sessions are enabled to enlist in distributed transactions. Valid values are 0 (disabled) and 1 (enabled). The default is 1 which indicates that sessions are enabled for distributed transaction enlistments. Applications using Microsoft Distributed Transaction Coordinator must have DistribTX set to 1, the default. Sessions enabled for distributed transaction enlistments cannot run statements that use the direct path load and parallel DML capabilities of the Oracle database. Such statements are executed as conventional path serial statements. Enhanced Failover Capability This feature enhances failover capability. These connection string attributes support enhanced failover capability. DBNotifications The DBNotifications attribute specifies whether or not to subscribe to high availability events. Valid values are 0 (FALSE) and 1 (TRUE). The default is FALSE, which indicates that OraOLEDB does not subscribe to high availability events. If this attribute is not provided at the connection time, then the default registry value is used. DBNotificationPort The DBNotificationPort attribute specifies the port number, which is used to listen to the database notifications. The valid value is an unsigned integer. DBNotificationPort is effective only if the DBNotifications attribute is set to TRUE, either through the connection string attribute or by registry entry. The default for the DBNotificationPort attribute is 0, which implies that OraOLEDB opens a valid port randomly. OraOLEDB does not validate the port number, so it is the responsibility of the application to specify a valid port number. Enabling Failover Capability Through Registry Entry DBNotifications The DBNotifications registry entry specifies whether or not to subscribe to high availability events. Valid values are 0 (FALSE) and 1 (TRUE). The default value is FALSE, OraOLEDB does not subscribe. This registry entry value is used when the DBNotifications connection string attribute is not set. It is located under the \\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_HOMENAME\OLEDB registry key. Operating System Authentication The OSAuthent attribute specifies whether operating system authentication will be used when connecting to an Oracle Database. Valid values are 0 (disabled) and 1(enabled). The default is 0, which indicates that operating system authentication is not used. Operating system authentication is the feature by which Oracle uses the security mechanisms of the operating system to authorize users. For more information on this subject and how to set it up on Windows clients, refer to the information on authenticating database users on Windows in Oracle Database Platform Guide for Microsoft Windows. After the Windows client has been set up properly for operating system authentication, this feature may be enabled by OraOLEDB clients by setting any of the following: DBPROP_AUTH_USERNAME to / DBPROP_INIT_PROVIDERSTRING to OSAuthent=1; OSAuthent in the registry to 1 Password Expiration Oracle provides a Password Expiration feature which allows database administrators to force users to change their passwords regularly. The PwdChgDlg attribute enables or disables the displaying of the password change dialog box, whenever a logon fails due to an expired password. When enabled, the provider displays the dialog box to change the password. When disabled, the logon fails with an error message. The valid values are 0 (disabled) and 1 (enabled). The default is 1 (enabled). For more information on the Password Expiration feature, see Oracle Database Security Guide.
这不是鸭头 2020-06-01
  • 打赏
  • 举报
回复
sql server 和Oracle的连接字符串不同

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧