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
ADO
As we saw in the last chapter, ActiveX Data Objects (ADO) access data from OLE DB providers. The Connection object is used to specify a particular provider and any parameters. To connect to a data source, you use a Connection object. Using that connection, you can create a new record set, and using the Recordset objects methods and properties, you can work with your data.
An ADO transaction marks the beginning and end of a series of data operations that are executed across a connection. ADO makes sure that changes to a data source resulting from operations in a transaction either all occur successfully, or not at all. If you cancel the transaction or one of its operations fails, then the result will be as if none of the operations in the transaction had occurred.
In this chapter, well see how to create connections using the ADO Connection object and how to open data providers, creating an ADO Recordset object. Well read data from the data provider and see how to display and modify it. In fact, well see how to support data-bound controls directly in code.
Although the ADO model is a complex one, and OLE DB is even more complex, well see that many of the core ADO Resultset methods are the same as the DAO Resultset methods.
TIP: Note that in DAO and ADO you work with record sets, and in RDO with result sets; its very easy to confuse the terminology here.
Thats it, then, for the overview of databases. Weve seen how the process works in overview; now its time to turn to the Immediate Solutions.
Immediate Solutions
A Full-Scale DAO Example
To illustrate DAO data handling in code, well build a fully functional DAO projectthe daocode project. This program has a File menu with the following items:
New DatabaseCreates a new database.
Open DatabaseOpens a database.
Close DatabaseCloses the current database.
New TableCreates a new table.
SearchSearches the database.
SortSorts the database.
ExitExits the application.
Using The Daocode Example To Create And Edit A Database
To create a database file, select the New Database menu item. Next, add a table to that database with the New Table menu item, then add records to that table. When youre ready to store the database on disk, use the Close Database item.
WARNING! If you dont create a table in a database before trying to add data to a table in that database with the Add or Edit buttons, the daocode program generates an error.
In addition, the program has buttons that let users add, edit, update, and delete records, as well as letting them move through a database, as shown in Figure 25.1. Each time you want to add a record (including when you enter the first record of a new database), click the Add New Record button, type in the data for the records fields, and click the Update Database button to update the database.
Figure 25.1 Our DAO database-building application, the daocode project.
To edit a record, open the record, click the Edit button, edit the data in the records fields, and click the Update Database button to update the database. For simplicity, this program only creates tables with two fields, although you can place as many records as you like in each table.
Well develop the code for this example program in the next several topics of this chapter. For reference, the main form of this example program is located in the daocode folder on this books accompanying CD-ROM; the form the user uses to specify the names of the fields in a new table is located in the TableForm folder on CD-ROM; and the code for the form in which the user can enter a text string to search for is located in the SearchForm folder on the CD-ROM.
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:
857 (2)mbdch20 857857 859857 859M S Szarzyński i D Naborowski o wartościach trwałych i~854851 854854 04mbdch20 854więcej podobnych podstron