Use ODBCDirect with Microsoft Access

Use ODBCDirect with Microsoft Access

Note: To ensure compliance with upcoming versions of Internet Explorer, we are deprecating the use of some ActiveX controls on the site. Our apologies for the inconvenience. For alternatives, try viewing the Office 2003 VBA References or Office XP VBA Language References.

What Is ODBCDirect?

ODBCDirect is a technology that enables you to work with ODBC database servers without loading the Microsoft Jet database engine. ODBCDirect relies on the Microsoft DAO 3.6 object model, so that you can easily modify your existing DAO code to take advantage of ODBCDirect. Microsoft DAO 3.6 includes new objects, methods, and properties to support ODBCDirect.

Advantages of Accessing ODBC Data with ODBCDirect

ODBCDirect offers the following advantages for ODBC operations:

  • ODBCDirect can make your code faster and more efficient by providing direct access to ODBC data sources. Since it doesn't require loading the Microsoft Jet database engine, ODBCDirect consumes fewer resources on the client side. The ODBC server is responsible for all query processing.

  • ODBCDirect gives you improved access to server-specific features that aren't available by using ODBC through Microsoft Jet. For example, for servers that support cursor specification, ODBCDirect allows you to specify where cursors are located, whether locally or on the server. In addition, to interact with stored procedures at the server level, you can specify input values and check return values, which you can't do when using Microsoft Jet.

  • ODBCDirect also supports asynchronous queries. When you execute a query, you don't have to wait for the query to finish running before you begin another operation. You can track the query's execution by checking the StillExecuting property.

  • ODBCDirect supports batch updating, enabling you to cache Recordset object changes locally and then submit these changes to the server in a single batch.

  • With ODBCDirect, you can create simple cursorless result sets, or more complex cursors. You can also run queries that return any number of result sets. You can limit the number of rows returned and monitor all the messages and errors generated by the remote data source without affecting the performance of the executing query.

Creating an ODBCDirect Workspace

You can create an ODBCDirect workspace by specifying the constant dbUseODBC for the type argument of the CreateWorkspace method. You can also specify that an ODBCDirect workspace be created by default by setting the DefaultType property of the DBEngine object.

Once you've created an ODBCDirect workspace, you can use specific DAO objects, properties, and methods to work with data on the ODBC database server.

Advantages of Accessing ODBC Data with Microsoft Jet

Microsoft Jet and ODBCDirect workspaces provide different but complementary functionality. You should use a Microsoft Jet workspace to access .mdb files and ISAM data formats, such as text and spreadsheets. Microsoft Jet provides unique capabilities that aren't available through ODBCDirect, including the following:

  • Updatable joins. You must use a Microsoft Jet workspace to update data in Recordset objects based on multiple-table joins.

  • Heterogeneous joins. You must use a Microsoft Jet workspace to perform joins of tables in different data sources.

  • Data Definition Language (DDL) operations. You must use a Microsoft Jet workspace to perform DDL operations using DAO. ODBCDirect doesn't provide a TableDef object, so you can't create or modify tables by using DAO. You can, however, perform DDL operations by using ODBCDirect to execute SQL DDL statements.

  • Form and control binding. If your application requires that forms or controls be bound to data in an ODBC data source, you must use Microsoft Jet. Data accessed within an ODBCDirect workspace can't be bound to forms or controls.

     

If you don't need these capabilities, you can use an ODBCDirect workspace.

Note   You can define both Microsoft Jet and ODBCDirect workspaces in your applications and mix them in any fashion. For example, in the same function, you can define a Microsoft Jet workspace to perform DDL operations using DAO and you can also define an ODBCDirect workspace to perform asynchronous queries.

<script language="VBScript" src="ShowMe_Code.vbs" type="text/javascript"></script> <script language="VBSCRIPT" type="text/javascript"> Sub HelpPopup(sFile,sID) L_SecurityT1_ErrorMessage="Help can't show you this procedure because the security setting in your browser is set too high" L_SecurityT2_ErrorMessage="or the ActiveX control Ouactrl.ocx didn't install correctly." L_SecurityE1_ErrorMessage="- Select a lower security setting in your browser" L_SecurityE2_ErrorMessage="- If you receive this message after selecting a lower security setting, please see your system" L_SecurityE3_ErrorMessage=" administrator for help troubleshooting the installation of the ActiveX control Ouactrl.ocx" L_SecurityE4_ErrorMessage=" located in the folder you installed Microsoft Office to." sSecurityMSG=L_SecurityT1_ErrorMessage & chr(13) & L_SecurityT2_ErrorMessage & chr(13) & chr(13) & L_SecurityE1_ErrorMessage & chr(13) & L_SecurityE2_ErrorMessage & chr(13) & L_SecurityE3_ErrorMessage & chr(13) & L_SecurityE4_ErrorMessage L_App_DialogTitle="Microsoft Office Help" On Error Resume Next r=oua.HelpPopup(sFile,sID) If Err<>0 Then Msgbox sSecurityMSG,48,L_App_DialogTitle End Sub </script>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值