Create a brand new project,
Add a Listbox,
Add a PushButton and place the code below:
[code]Sub Action() Handles Action
Dim Open_Dlg As New OpenDialog
Dim Open_FI As FolderItem
Dim FT_SQLite As New FileType
FT_SQLite.Name = “sqlite/db”
FT_SQLite.MacType = “”
FT_SQLite.MacCreator = “”
FT_SQLite.Extensions = “sqlite”
// Ask the user (you) to choose the bad db structure file
Open_Dlg.Title = “Select a .sqlite file”
Open_Dlg.Filter = FT_SQLite
Open_FI = Open_Dlg.ShowModal
If Open_FI = Nil Then
// User Cancelled
Return
End If
Dim db As New SQLiteDatabase
db.DatabaseFile = Open_FI
If Not db.Connect Then
MsgBox("The database couldn’t be opened. Error: " + db.ErrorMessage)
Return
End If
// Fill the Listbox Headers
Listbox1.ColumnCount = 5 // Just in case
Listbox1.Heading(-1) = “Type” + Chr(9) + “Name” + Chr(9) + “Tbl_Name” + Chr(9) + “Root_Page” + Chr(9) + “SQL”
// Fill the Listbox with the sqlite_master data
Dim SM_RS As RecordSet
SM_RS = db.SQLSelect(“SELECT * FROM sqlite_master”)
If SM_RS = Nil Then
MsgBox “SM_RS is Nil”
Return
End If
If db.Error Then
MsgBox “An error occured” + EndOfLine + EndOfLine +_
"Error " + Str(db.ErrorCode) + ": " + db.ErrorMessage + “.”
Return
End If
// Clears the previous contents
Listbox1.DeleteAllRows
// To store the newly added Row # (used in the loop below)
Dim Loc_Row As Integer
// Scan and report each Record contents
While Not SM_RS.EOF
// Get the data from each Record and display them in the Listbox
Listbox1.AddRow SM_RS.Field(“type”).StringValue
Loc_Row = Listbox1.LastIndex
Listbox1.Cell(Loc_Row,1) = SM_RS.Field(“name”).StringValue
Listbox1.Cell(Loc_Row,2) = SM_RS.Field(“tbl_name”).StringValue
Listbox1.Cell(Loc_Row,3) = SM_RS.Field(“rootpage”).StringValue
Listbox1.Cell(Loc_Row,4) = SM_RS.Field(“sql”).StringValue
// Next Record, please
SM_RS.MoveNext
// To avoid infinite loop
If UserCancelled Then Exit
Wend
End Sub[/code]
Run.
If everything went OK, you have the contents of the sqlite_master RecordSet:
TABLE names and CREATE string (to create the TABLE).
Select a Row and Paste its contents in a text editor to watch the complete CREATE line.