; ; ------------------------------------------------------------ ; ; PureBasic - Database example file ; ; (c) 2001 - Fantaisie Software ; ; ------------------------------------------------------------ ; If InitDatabase() = 0 MessageRequester("Error", "Can't initialize Database (ODBC v3 or better) environment", 0) End EndIf OpenConsole() Dim DatabaseType.s(4) DatabaseType(0) = "Unknown" DatabaseType(1) = "Numeric" DatabaseType(2) = "String" DatabaseType(3) = "Float" ; First, let's see which drivers are attached to the system.. ; If ExamineDatabaseDrivers() While NextDatabaseDriver() PrintN(DatabaseDriverName()+" - "+DatabaseDriverDescription()) Wend EndIf ; Open an ODBC database ; If OpenDatabaseRequester(0) PrintN("Database successfully opened !") PrintN("Type EXIT to quit.") PrintN("Command example: select * from user;") Repeat Print("SQL Command: ") Command$ = Input() PrintN("") Select UCase(Command$) Case "EXIT" Quit = 1 Default If DatabaseQuery(Command$) NbColumns = DatabaseColumns() PrintN("NbColums: " + Str(NbColumns)) For k=0 To NbColumns-1 PrintN(DatabaseColumnName(k) + " - " + DatabaseType(DatabaseColumnType(k))) Next PrintN("") Print ("Press return to continue") : Input() PrintN("") PrintN("Query Result -------------------------------------") While NextDatabaseRow() PrintN(GetDatabaseString(0)) Wend PrintN("--------------------------------------------------") Else PrintN("Bad Query !") EndIf EndSelect Until Quit = 1 Else MessageRequester("Info", "Operation canceled", 0) EndIf End ; ExecutableFormat=Console ; EOF