ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaik_5.4.0.1/rzaikvb5jetodbc.htm

114 lines
8.4 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Visual Basic: The compromise between Jet and ODBC APIs" />
<meta name="abstract" content="While the database objects are easy to code, they sometimes can adversely affect performance. Coding to the APIs and to stored procedures can be a frustrating endeavor. Fortunately, if you are using Visual Basic Enterprise Edition in the Windows 95 environment, there are additional options. These options are a good compromise between the usability of database objects and the high performance of APIs: Remote Data Objects (RDO) and Remote Data Control (RDC)." />
<meta name="description" content="While the database objects are easy to code, they sometimes can adversely affect performance. Coding to the APIs and to stored procedures can be a frustrating endeavor. Fortunately, if you are using Visual Basic Enterprise Edition in the Windows 95 environment, there are additional options. These options are a good compromise between the usability of database objects and the high performance of APIs: Remote Data Objects (RDO) and Remote Data Control (RDC)." />
<meta name="DC.Relation" scheme="URI" content="rzaikdirectcodeodbcapis.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="vb5jetodbc" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Visual Basic: The compromise between Jet and ODBC APIs</title>
</head>
<body id="vb5jetodbc"><a name="vb5jetodbc"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Visual Basic: The compromise between Jet and ODBC APIs</h1>
<div><p>While the database objects are easy to code, they sometimes can
adversely affect performance. Coding to the APIs and to stored procedures
can be a frustrating endeavor. Fortunately, if you are using Visual Basic
Enterprise Edition in the Windows<sup>®</sup> 95 environment, there are additional
options. These options are a good compromise between the usability of database
objects and the high performance of APIs: Remote Data Objects (RDO) and Remote
Data Control (RDC).</p>
<div class="section"><p>RDO is a thin layer over the ODBC APIs. It provides a simple interface
to advanced ODBC functionality without requiring programming to the API level.
It does not have all of the overhead of the Jet Engine controlled Data Access
Object (DAO) or its <span class="keyword">SQL</span> optimizer.
Yet it maintains a nearly identical programming interface as the DAOs. If
you understand programming to the DAO, then switching over to the RDO is relatively
simple compared to trying to switch over to API calls.</p>
</div>
<div class="section"><p>The following are differences between DAO and RDO: </p>
<ul><li>The DAO model is used for ISAM, Access and ODBC databases. The RDO model
is designed for ODBC databases only, and it has been optimized for Microsoft<sup>®</sup> <span class="keyword">SQL</span> Server 6.0 and Oracle.</li>
<li>The RDO model can have better performance, with the processing being done
by the server and not the local machine. Some processing is done locally with
the DAO model, so performance may not be as good.</li>
<li>The DAO model uses the Jet Engine. The RDO model does not use Jet Engine,
it uses the ODBC backend engine.</li>
<li>The RDO model has the capability to perform synchronous or asynchronous
queries. The DAO model has limitations in performing these type of queries.</li>
<li>The RDO model can perform complex cursors, which are limited in the DAO
model.</li>
</ul>
</div>
<div class="section"><p>The RDC is a data control similar to the standard data control.
This means that where ever you might have used a data control, and the Jet
engine, you now can use the RDC. You can drag a "data aware" control on your
form. It can be bound to an RDC, as it could be bound to a regular data control.</p>
</div>
<div class="section"><p>Some of the advanced ODBC functionality the RDO allows is prepared <span class="keyword">SQL</span> statements, multiple result
sets, and stored procedures. When Jet executes a <span class="keyword">SQL</span> statement
dynamically it is a two-step process on the iSeries™ server. In the first step, the iSeries server
looks at the statement and determines the best plan to retrieve the data requested
based on the current database schema. In the second step, that plan is used
to actually retrieve the data. Creating that plan can be expensive in terms
of time because the iSeries server has to evaluate many alternatives
and determine the best way to access the data. There is an alternative to
forcing the iSeries server
to recreate the access plan every time a <span class="keyword">SQL</span> statement
is run. The <strong>CreatePreparedStatement</strong> method of the <strong>rdoConnection</strong> object
allows you to compile a data access plan on the iSeries server for an <span class="keyword">SQL</span> statement
without executing it. You can even include parameters in prepared statements,
so you can pass new selection criteria every time you run the select statement.</p>
</div>
<div class="section"><p>The following sample Visual Basic code will show how to prepare
a <span class="keyword">SQL</span> statement with
a parameter marker and run it multiple times with different values.</p>
</div>
<div class="section"><div class="fignone"><span class="figcap">Figure 1. Visual Basic 4.0 RDO sample code</span><br /><img src="vb4001.gif" alt="VB 4.0 RDO sample code" /><br /></div>
</div>
<div class="section"><p>Label A shows where the <span class="keyword">SQL</span> statement
is defined. Notice that the statement does not include a specific for the
CUSTNUM, but has a question mark for the value. The question mark signifies
that this value is a parameter of the prepared statement. Before you can create
a result set with the prepared statement, you must set the value of any parameters
in the statement.</p>
</div>
<div class="section"><p>Label B shows where the value for the parameter is defined. Notice
that the first parameter is defined as 0 not as 1. Once the value for the
parameter is set you can run the <strong>OpenResultSet</strong> method of the <strong>rdoPreapredStatement</strong> to
return the requested data.</p>
</div>
<div class="section"><p>Before you can re-query a prepared statement on the iSeries server,
you have to make sure that the cursor has been completely processed and closed.
Label C shows the <strong>MoreResults</strong> method of the <strong>rdoResultSet</strong> being
used to do this. The <strong>MoreResults</strong> method queries the database. It determines
if there is any more data in the result set to be processed, or if the result
set has been processed completely. Once the cursor has been fully processed
you can reset the parameter value and run the <strong>ReQuery</strong> method of the <strong>rdoResultSet</strong> to
open a new result set.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaikdirectcodeodbcapis.htm" title="Many PC applications make ODBC calls that allow the user to seamlessly access data on different platforms. Before you begin developing your own application with ODBC APIs, you should understand how an ODBC application connects to and exchanges information with a database server.">Code directly to ODBC APIs</a></div>
</div>
</div>
</body>
</html>