HOWTO: Delete Tables from a Windows CE Device from VBCE
ID: Q207562
|
The information in this article applies to:
-
Microsoft Windows CE Toolkit for Visual Basic 6.0, version 1.0
-
Microsoft Windows CE Toolkit for Visual Basic 5.0, version 1.0
SUMMARY
There is currently no functionality provided on a Windows CE device by which database tables existing in the database store can be directly deleted. This article illustrates how this can be accomplished from a Windows CE Toolkit for Visual Basic (VBCE) application.
MORE INFORMATION
The following steps illustrate how to delete non system tables from the database store. The assumption is made that there are already tables in existence on the Windows CE device that can be deleted.
Step by Step Example
- Start a new Windows CE Handheld PC (HPC) project in Visual Basic. Form1 is created by default.
- Place a list box and a command button on Form1.
- Paste the following code into the code window of Form1:
Option Explicit
Private Sub Form_Load()
Dim MyRecordSet
Dim lMyRecordCount As Long
Dim lRecordIndex As Long
Dim sMyTable As String
'initialize controls
Command1.Caption = "Drop Selected Tables"
Form1.Caption = "CE Drop Tables"
Command1.Move 60, 1920, 4695, 495
List1.Move 60, 60, 4695, 1815
Form1.Move 0, 0, 4950, 2880
' Load the ListBox with the Names of Non-System Tables.
Form1.List1.Clear
Set MyRecordSet = CreateObject("ADOCE.Recordset")
MyRecordSet.Open "MSysTables", "", 1, 3
lMyRecordCount = MyRecordSet.RecordCount
For lRecordIndex = 0 To lMyRecordCount - 1
sMyTable = MyRecordSet.Fields("TableName").Value
If Mid(sMyTable, 1, 4) <> "MSys" Then
Form1.List1.AddItem sMyTable
End If
MyRecordSet.MoveNext
Next
MyRecordSet.Close
End Sub
Sub Command1_Click()
Dim iIndex As Integer
Dim MyRecordSet
Set MyRecordSet = CreateObject("ADOCE.Recordset")
For iIndex = Form1.List1.ListCount - 1 To 0 Step -1
If Form1.List1.Selected(iIndex) Then
MyRecordSet.Open "DROP TABLE [" & _
Form1.List1.List(iIndex) & "]", , 2, 3
Form1.List1.RemoveItem (iIndex)
End If
Next
End Sub
- Run the project.
Note that you can select and delete the non system tables from the database store of your Windows CE device.
REFERENCES
For additional information about Microsoft ADO for Windows CE SDK (ADOCE), please click the article numbers below to view the articles in the Microsoft Knowledge Base:
Q196034 HOWTO: Use ADOFILTR.DLL to Transfer Database Tables
Q221594 HOWTO: Populate a ListView With an ADOCE Recordset in VBCE6
Q192531 INFO: Overview of ADO for Windows CE SDK (ADOCE)
Q238947 FILE: Msadoce2.exe Installs ADO for Windows CE SDK
Additional query words:
kbDSupport
Keywords : kbToolkit kbVBp500 kbVBp600 kbWinCE kbGrpVB kbCodeSnippet
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbhowto