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
RDO: Moving To The First Record In A Result Set
To move to the first record in an RDO result set, you can use the rdoResultset method MoveFirst. Lets see an example. In this case, well move to the first record in the result set named resultset that weve opened in our RDO code example, the rdocode project (see A Full-Scale RDO Example earlier in this chapter), when the user clicks the appropriate button:
Private Sub cmdFirst_Click()
On Error GoTo ErrLabel
resultset.MoveFirst
...
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
After moving to the new record, we display the data in that records fields in the programs text boxes, Text1 and Text2:
Private Sub cmdFirst_Click()
On Error GoTo ErrLabel
resultset.MoveFirst
Text1.Text = resultset("Name")
Text2.Text = resultset("Grade")
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
RDO: Moving To The Last Record In A Result Set
To move to the last record in an RDO result set, you can use the rdoResultset method MoveLast. Lets see an example. In this case, well move to the last record in the result set named resultset that weve opened in our RDO code example, the rdocode project (see A Full-Scale RDO Example earlier in this chapter), when the user clicks the appropriate button:
Private Sub cmdLast_Click()
On Error GoTo ErrLabel
resultset.MoveLast
...
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
After moving to the new record, we display the data in that records fields in the programs text boxes, Text1 and Text2:
Private Sub cmdLast_Click()
On Error GoTo ErrLabel
resultset.MoveLast
Text1.Text = resultset("Name")
Text2.Text = resultset("Grade")
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
RDO: Moving To The Next Record In A Result Set
To move to the next record in an RDO result set, you can use the rdoResultset method MoveNext. Lets see an example. In this case, well move to the next record in the result set named resultset that weve opened in our RDO code example, the rdocode project (see A Full-Scale RDO Example earlier in this chapter), when the user clicks the appropriate button. We check to make sure were not trying to move past the end of the record set with the EOF property, and if so, we make sure to move to the last record instead:
Private Sub cmdNext_Click()
On Error GoTo ErrLabel
If Not resultset.EOF Then resultset.MoveNext
If resultset.EOF And resultset.RowCount > 0 Then
resultset.MoveLast
End If
...
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
After moving to the new record, we display the data in that records fields in the programs text boxes, Text1 and Text2:
Private Sub cmdNext_Click()
On Error GoTo ErrLabel
If Not resultset.EOF Then resultset.MoveNext
If resultset.EOF And resultset.RowCount > 0 Then
resultset.MoveLast
End If
Text1.Text = resultset("Name")
Text2.Text = resultset("Grade")
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
RDO: Moving To The Previous Record In A Result Set
To move to the previous record in an RDO result set, you can use the rdoResultset method MovePrevious. Lets see an example. In this case, well move to the previous record in the result set named resultset that weve opened in our RDO code example, the rdocode project (see A Full-Scale RDO Example earlier in this chapter), when the user clicks the appropriate button. We check to make sure were not trying to move past the beginning of the record set with the BOF property, and if so, we make sure to move to the first record instead:
Private Sub cmdPrevious_Click()
On Error GoTo ErrLabel
If Not resultset.BOF Then resultset.MovePrevious
If resultset.BOF And resultset.RowCount > 0 Then
resultset.MoveFirst
End If
Text1.Text = resultset("Name")
Text2.Text = resultset("Grade")
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
After moving to the new record, we display the data in that records fields in the programs text boxes, Text1 and Text2:
Private Sub cmdPrevious_Click()
On Error GoTo ErrLabel
If Not resultset.BOF Then resultset.MovePrevious
If resultset.BOF And resultset.RowCount > 0 Then
resultset.MoveFirst
End If
Text1.Text = resultset("Name")
Text2.Text = resultset("Grade")
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
RDO: Executing SQL
You can execute SQL statements with RDO objects when you open a result set, as we saw in RDO: Creating A Result Set in this chapter. You can also execute an SQL statement with the rdoConnection objects Execute statements like this:
SQLSel = "Select * from students"
rdoConnection.Execute SQLSel
A Full-Scale ADO Example
To illustrate ADO data handling in code, well build an ADO projectthe adocode project. This application lets you open the db.mdb file we built in the previous chapter using ADO objects to edit records, add records, and even delete records. You can also move through the database using the arrow buttons you see in Figure 25.5.
Figure 25.5 The adocode project at work.
To edit a record, just type the new value(s) into the text box(es) and click the Update button. To add a record, use the Add button, type the new value(s) into the text box(es), and click the Update button. Thats all there is to ityour changes will be reflected in the original database. For reference, the code for this example is located in the adocode folder on this books accompanying 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:
876 879README (879)879 882884 886ReadMe (884)884 887882 884więcej podobnych podstron