Download presentation
Presentation is loading. Please wait.
Published byEsmond French Modified over 9 years ago
1
Sept 2001 cylauFoxpro Chapter 41 Chapter 4 Accessing Database Tables
2
Sept 2001 cylauFoxpro Chapter 42 Create a table zFields in Visual FoxPro yCharacter(254 bytes) yNumeric/Float(20 bytes) yDate/DateTime(8 bytes/8 bytes) yInteger(4 bytes) yLogical(1 byte) yCurrency(8 bytes) yMemo(4 bytes + unlimited)
3
Sept 2001 cylauFoxpro Chapter 43 USE and CLOSE zUSE file1&& file1 is used zUSE file2&& file2 is used, file1 closed zUSE&& file2 is closed zCLOSE DATABASES&& close all files note: you may open 2 or more files at the same time see chapter 7
4
Sept 2001 cylauFoxpro Chapter 44 MODIFY STRUCTURE zFields in a table can be modified using the MODIFY STRUCTURE Command yAdding new fields yDeleting existing fields yChanging name, type or length of fields zData in the table may be lost if you ydelete a column ychange the type of a column zWhat about change name or length?
5
Sept 2001 cylauFoxpro Chapter 45 How to Recover the Original File? zSave File1 for the first time File1.dbf zWhen File1 is revised and saved File1.bak (original) and File1.dbf (revised) zWhen File1 is revised and saved again File1.bak (original) and File1.dbf (revised) COPY FILE File1.bak TO File1.dbf
6
Sept 2001 cylauFoxpro Chapter 46 SET DEFAULT TO zSET DEFAULT TO c:\aFox yFiles will be searched under this directory (c:\aFox) yNewly created files will be placed here (c:\aFox) zSET PATH TO a:\ yFiles not found in c:\aFox will be searched under the directory specified by the path (a:\) zSET PATH TO u:\student\olc06145 yWhere will newly created files be saved? yWhat about original file?
7
Sept 2001 cylauFoxpro Chapter 47 LIST, BROWSE, EDIT... zLIST&& all records and fields zSET FIELDS TO yrestrict columns to be displayed zSET FILTER TO yrestrict rows to be displayed zLIST/BROWSE/EDIT FIELDS … FOR … yFIELDS - restrict columns to be displayed yFOR - restrict rows to be displayed
8
Sept 2001 cylauFoxpro Chapter 48 Accessing a Specific Record Suppose a file has 3 records BOF -- 1 -- 2 -- 3 -- EOF Let Rptr = record pointer zGO TOPRptr --> 1recno()=1 zGO BOTTOMRptr --> 3recno()=3 zSKIP -3Rptr --> BOFrecno()=1 not 0 zSKIPRptr --> 1recno()=1 zSKIP 3Rptr --> EOFrecno()=4 not 3
9
Sept 2001 cylauFoxpro Chapter 49 Useful Functions RECCOUNT() EOF() BOF() Suppose a file has 3 records BOF -- 1 -- 2 -- 3 -- EOF zRECCOUNT()=3total number of records zGO TOPBOF()=.F.EOF()=.F. zGO BOTTOMBOF()=.F.EOF()=.F. zSKIP -3BOF()=.T.EOF()=.F. zSKIPBOF()=.F.EOF()=.F. zSKIP 3BOF()=.F.EOF()=.T.
10
Sept 2001 cylauFoxpro Chapter 410 Accessing the Memo Field zDouble click the “memo” field of a record zA text editing window will appear zPress Control-W to close the window
11
Sept 2001 cylauFoxpro Chapter 411 Displaying Contents of a Record ClassName 7AChan 7SWong GO BOTTOM ?Name&& Wong ?Name=‘Cheung’&& a variable ?Name&& Wong ?m->Name&& Cheung
12
Sept 2001 cylauFoxpro Chapter 412 Exercise zP.121 yQ.1, Q.2, Q.3, Q.4 zP.122 yQ.11 zP.123 yQ.13 zP.124 yQ.15
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.