851 854




Visual Basic 6 Black Book:Working With Database Objects In Code
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Visual Basic 6 Black Book (Publisher: The Coriolis Group) Author(s): Steven Holzner ISBN: 1576102831 Publication Date: 08/01/98 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




Chapter 25Working With Database Objects In Code


If you need an immediate solution to:
A Full-Scale DAO Example
Using The Daocode Example To Create And Edit A Database
DAO: Creating A Database
DAO: Creating A Table With A TableDef Object
DAO: Adding Fields To A TableDef Object
DAO: Adding An Index To A TableDef Object
DAO: Creating A Record Set
DAO: Opening A Database
DAO: Adding A Record To A Record Set
DAO: Editing A Record In A Record Set
DAO: Updating A Record In A Record Set
DAO: Moving To The First Record In A Record Set
DAO: Moving To The Last Record In A Record Set
DAO: Moving To The Next Record In A Record Set
DAO: Moving To The Previous Record In A Record Set
DAO: Deleting A Record In A Record Set
DAO: Sorting A Record Set
DAO: Searching A Record Set
DAO: Executing SQL
A Full-Scale RDO Example
RDO: Opening A Connection
RDO: Creating A Result Set
RDO: Moving To The First Record In A Result Set
RDO: Moving To The Last Record In A Result Set
RDO: Moving To The Next Record In A Result Set
RDO: Moving To The Previous Record In A Result Set
RDO: Executing SQL
A Full-Scale ADO Example
ADO: Opening A Connection
ADO: Creating A Record Set From A Connection
ADO: Binding Controls To Record Sets
ADO: Adding A Record To A Record Set
ADO: Refreshing The Record Set
ADO: Updating A Record In A Record Set
ADO: Moving To The First Record In A Record Set
ADO: Moving To The Last Record In A Record Set
ADO: Moving To The Next Record In A Record Set
ADO: Moving To The Previous Record In A Record Set
ADO: Deleting A Record In A Record Set
ADO: Executing SQL In A Record Set

In Depth
Programming database objects is an enormously complex topic that in itself can take up a dozen volumes. There is a career’s worth of work here, so we’ll have our hands full in this chapter.

Here, we’re going to perform many of the tasks we first saw in the previous chapter, but while we used the data, remote data, and ADO data controls in that chapter, we’ll execute those tasks in code directly in this chapter, using the Visual Basic data object libraries. Working with the data object libraries provides more flexibility, more power—and a great deal more complexity.
DAO
We’ll use Data Access Object (DAO) methods to do what we did in the beginning of the last chapter: build a database and allow users to move through that database, editing it as they like. To construct a database, we’ll create it, create a table with fields and add it to that database, and also construct an index for the database that will let us sort it.
Working with DAO, you can use the Database and Recordset Data Access Objects in your procedures. The Database and Recordset objects each have properties and methods of their own, and you can write procedures that use these properties and methods to manipulate your data.

TIP:  Note that in the Learning Edition of Visual Basic, you can’t declare (with the Dim keyword) variables as Data Access Objects in code. This means that only the data control can create Database and Recordset objects, not your code.

To open a database in DAO, you just open a Database object or create a new one. This object can represent a Microsoft Jet database (.mdb) file, an ISAM database (for example, Paradox), or an ODBC database connected through the Microsoft Jet database engine. When the Database object is available, you create a Recordset object and use that object’s methods, like MoveFirst and MoveNext, to work with the database.
DAO also supports a client/server connection mode called ODBCDirect. ODBCDirect establishes a connection directly to an ODBC data source, without loading the Microsoft Jet database engine into memory, and is a good solution when you need ODBC features in your program.
In the ODBCDirect object model, the Connection object contains information about a connection to an ODBC data source, such as the server name, the data source name, and so on. It is similar to a Database object; in fact, a Connection object and a Database object represent different references to the same object. (In this chapter, we’ll stick with the Database/Recordset model.)
RDO
With the Remote Data Objects (RDO) library of data objects, you establish an rdoConnection to an ODBC data source, then create an rdoResultset (please note, it is not an rdoRecordset). The Remote Data Objects behave like the DAO objects in many ways, because there is a core set of methods that work with both record sets and result sets.

The big difference between DAO and RDO objects is that the RDO objects are largely SQL-driven. For example, although you can move through a database using methods like MoveNext and MoveLast, just as you would with the DAO objects, programmers often update and modify RDO data sources using SQL statements directly with the rdoConnection object’s Execute method. (In this book, we’ll stick to what you can do with Visual Basic.)



Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.



Wyszukiwarka

Podobne podstrony:
854 857
851 (2)
MCINTOSH MVP 851
M S Szarzyński i D Naborowski o wartościach trwałych i~854
851 856
854 04
mbdch20 854
849 851

więcej podobnych podstron