Thursday, August 27, 2009

VB6: Cellphone database, database manipulation Part 1b

With some little modification, we could extract records


Dim gLibWS As Workspace
Dim gLibDB As Database
Dim gLibDyna As Recordset
Dim gLibSnap As Recordset
Dim gLibTable As Recordset
Dim gDbName As String
Dim ftFldName$
Dim ftFld$

gDbName = App.Path & "\phone.mdb"

' Print database name with path to debug screen
Debug.Print gDbName

Set gLibWS = DBEngine.CreateWorkspace("Workspace", "Admin", "")

' Open DataBase with Exclusive and Read/Write access
Set gLibDB = gLibWS.OpenDatabase(gDbName$, True, False)
Set gLibSnap = gLibDB.OpenRecordset("cellphone", dbOpenSnapshot)
giFldTotal% = gLibDB.TableDefs("cellphone").Fields.Count - 1

' Print total of fields in the debug windows
Debug.Print "Total of fields: " & giFldTotal%

For fiIndex% = 0 To giFldTotal% - 1
' Extract name of fields name
ftFldName$ = CStr(gLibDB.TableDefs("cellphone").Fields(fiIndex%).Name)
' Extract fields content, no need to use
' EOF since there is only one record
' Null will gives error, need error trapping
If Not IsNull(gLibSnap.Fields(fiIndex%)) Then
ftFld$ = CStr(gLibSnap.Fields(fiIndex%))
Else: ftFld$ = "Null"
End If
Debug.Print fiIndex% & " : " & ftFldName$ & " : "; ftFld$
Next fiIndex%




Output

D:\visual-basic-degree-final-project\phone.mdb
Total of fields: 53
0 : Phone_ID : 000001
1 : Phone_Manufacturer : Samsung
2 : Phone_Model : SGH-Z710
3 : Key_Feature_3G : False
4 : Key_Feature_Wifi : False
5 : Key_Feature_memory_card_slot : True
6 : Key_Feature_MP3 : True
7 : Key_Feature_QWERTY : False
8 : Key_Feature_camera : True
9 : Key_Feature_Bluetooth : True
10 : Key_Feature_GPS : False
11 : From_factor : Clamshell
12 : Data : GPRS/EDGE/UMTS
13 : Antenna_Design : Internal
14 : Operating_frequencies : 900/800/1900
15 : Global_Roaming : Yes
16 : Weight : 3.8 oz (108 g) the average is 2.3 oz (65 g)
17 : Dimensions : 3.8 x 1.9 x 0.8 (97 x 47.5 x 20.5 mm)
18 : Battery_Standby : 220 hours the average is 151 hours (6 days)
19 : Battery_Talktime : 3.00 hours the average is 4 h (240 min)
20 : Battery_Type : 880 mAH
21 : Display_Resolution : 240 x 320 pixels
22 : Display_Type : TFT
23 : Camera_Features : 4x Digital zoom Auto focus Additional camera for video calling
24 : Camera_Video : Yes
25 : Camera_Resolutions : 3.2 megapixels
26 : Memory_Expansion : microSD (T-Flash)
27 : Memory_Internal : 128 MB
28 : Conn_Infrared : No
29 : Conn_Bluetooth : 2.0
30 : Conn_Sync : --
31 : Conn_USB : Yes
32 : Conn_Wifi : --
33 : MM_Headset_Jack : --
34 : MM_Video_Playback : MPEG4 H.263 formats supported Video player
35 : MM_FM_Radio : Stereo FM Radio
36 : MM_Streaming : Yes
37 : MM_Music_Player : MP3 ACC ACC+WMA RA formats supported
38 : Size_Weight : 3.8 oz (108 g) the average is 2.3 oz (65 g)
39 : Size_Dimensions : 3.8 x 1.9 x 0.8 (97 x 47.5 x 20.5 mm)
40 : Messaging_E_Mail : IMAP / POP3 / SMTP
41 : Messaging_Instant_Messaging : --
42 : Messaging_Predictive_Text_Input : T9
43 : Messaging_MMS : Yes
44 : Software_to_do : Yes
45 : Software_Phonebook : Caller groups supported
46 : Software_Games : Yes
47 : Software_Java : MIDP 2.0
48 : Software_Calculator : Yes
49 : Software_Alarm : Yes
50 : Software_Calendar : Yes
51 : Software_Other_Organizers : World Clock Currencies Converter
52 : Official_URL : Null

No comments:

Post a Comment