With this class U can use 4 Database Type ( PostgreSQL, MySQL, MsSQL, Oracle )
In this case the class assume name DBKOALA…, U can rename this…
DB KOALA Database CLASS
For use of this class …
dim db as new DBKoala(procedure.dbdatabasetype)
db.DatabaseName = procedure.dbname // Remember pass conn string for Oracle
db.Host = procedure.dbhost
db.Port = procedure.dbport // Pass 0 for Oracle
db.Username = procedure.dbusername
db.Password = procedure.dbpassword
Obviously the construct DBKoala (dbname) can take:
"PostgreSQL"
"MySQL"
"MsSQL"
"Oracle"
If you want to change the name of the class you must rename the DB object be aware of all the various supported commands:
Close, Commit, Connect, ConnectionString, Error, Error code, ErrorMessage, FieldSchema, InsertRecord, Prepare, RollBack, SQLExecute, SQLSelect, TableSchema
I use a XML for app setting, in this XML have stored the DB parameter …
Like this
Dim f As FolderItem
f = GetFolderItem("settings.xml",0)
If f <> Nil Then
Dim xml As New XmlDocument
Try
xml.LoadXml(f)
dim configurazione as XmlNode
configurazione = xml.documentElement
dim xdbhost as String = xmlnoderead(configurazione,"host")
procedure.dbhost = xdbhost
dim xdatabasetype as string = xmlnoderead(configurazione,"databasetype")
procedure.dbdatabasetype = xdatabasetype
dim xdbname as String = xmlnoderead(configurazione,"databasename")
procedure.dbname = xdbname
dim xdbusername as string = xmlnoderead(configurazione,"username")
procedure.dbusername = xdbusername
dim xdbport as integer = cint(xmlnoderead(configurazione,"port"))
procedure.dbport = xdbport
dim xdbpassword as string = xmlnoderead(configurazione,"password")
procedure.dbpassword = xdbpassword
dim xconnstring as String = xmlnoderead(configurazione,"connstring")
procedure.dbconnstring = xconnstring
dim xportaudp as Integer = cint(xmlnoderead(configurazione,"portaudp"))
procedure.portaudp = xportaudp
if testdb() then
login.Show()
else
ConfigServer.Show
end if
Catch e As XmlException
// MsgBox("Errore xml: " + e.Message)
ConfigServer.Show
End Try
End If
And this are a config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- File di configurazione per KOALA ERP -->
<Configurazione xmlns:xml="http://www.w3.org/XML/1998/namespace">
<!-- File di configurazione per KOALA ERP -->
<host>localhost</host>
<databasetype>PostgreSQL</databasetype>
<databasename>minicontab</databasename>
<username>minicontab</username>
<password>minicontab</password>
<port>5432</port>
<!-- porta udp per lettore barcode wireless via android device -->
<portaudp>12345</portaudp>
</Configurazione>