Je souhaite faire un essai de connexion sur une base Oracle avec ODBC et j'ai systèmatiquement le message d'erreur : InitDatabase is not a function, array, macro...
Pour info, j'utilise Purebasic 4.10.
Voici le code de Flype que j'utilise :
Code : Tout sélectionner
If InitDatabase()
If OpenDatabase(0,"test_purebasic","","")
If DatabaseQuery(0, "SELECT NOW")
While NextDatabaseRow(0)
Debug GetDatabaseString(0, 0)
Wend
EndIf
EndIf
EndIf
Code : Tout sélectionner
;
; ------------------------------------------------------------
;
; 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(0, Command$)
NbColumns = DatabaseColumns(0)
PrintN("NbColums: " + Str(NbColumns))
For k=0 To NbColumns-1
PrintN(DatabaseColumnName(0, k) + " - " + DatabaseType(DatabaseColumnType(0, k)))
Next
PrintN("")
Print ("Press return to continue") : Input()
PrintN("")
PrintN("Query Result -------------------------------------")
While NextDatabaseRow(0)
PrintN(GetDatabaseString(0, 0))
Wend
PrintN("--------------------------------------------------")
Else
PrintN("Bad Query !")
EndIf
EndSelect
Until Quit = 1
Else
MessageRequester("Info", "Operation canceled", 0)
EndIf
End
Laurent