[Gambas-user] Missing images on the Wiki
ML
d4t4full at ...626...
Tue Jul 19 19:34:27 CEST 2016
Jesus,
Please note that, since Gambas 3.8.1, IIRC, gb.db.odbc was made to
support the so-called "Connection Strings".
I am responsible for this mess, and am still trying to enhance it. None
of the following is in the docs yet, AFAIK.
Instead of passing a Host named in the corresponding INI file, you may
well pass a Connection String.
The only real ODBC set-up (tested with unixODBC, not iODBC) left for the
user or sysadmin is the Driver configuration.
The huge advantage of using connection strings, in my humble opinion, is
that in order to use a different database engine you do not have to
change any code; just the string used to connect. And this string can be
part of the program configuration.
For example, assume unixODBC, and FreeTDS and MySQL drivers are
installed, and you have this odbcinst.ini:
[FreeTDS]
Description = FreeTDS Driver v0.91
Driver64 = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount = 1
DontDLCLose = 1
fileusage = 1
[MySQL]
Description = MySQL 5.1 ODBC Driver
Driver64 = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc5.so
Setup64 = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
UsageCount = 1
DontDLCLose = 1
fileusage = 1
You could connect with any FreeTDS- or MySQL- supported servers. No need
to edit other INI files. Gambas 3 example (note that I only set 2
properties of $conn):
Public $conn As Connection
Public Sub cmdConnect_Click()
Inc Application.Busy
Try $conn.Close 'In case the button is clicked again
SetStatus("Connecting...")
DB.Debug = chkDBDebug.Value
$conn.Type = "odbc"
$conn.Host = txtConnString.Text 'txtConnString is a textbox with a
(possibly) user-defined conn string.
$conn.Open
SetStatus("Connected OK to database '" & $conn.Name & "'")
Finally
Dec Application.Busy
Catch
SetStatus("Error connecting: " & Error.Text & " at " & Error.Where)
End
An example Connection String for FreeTDS that works with the code above
(placeholders in angle-brackets):
Driver=FreeTDS;TDS_Version=7.2;Server=<server IP or
Name>;Port=<usually 1433>;UId=<user
name>;Pwd=<password>;Database=<database name>
The Driver= keyword instructs unixODBC to use the FreeTDS section
defined in odbcinst.ini. All other keywords are particular to -and
dependant on- the driver selected.
This has been tested to work with MSSQL 2005 and 2008 servers.
One quirk it has that I still could not fix is to return the proper
database name in .Name. Looks like my C is not up to that task yet.
Regards,
On 2016-07-19 11:00, Jesus Guardon wrote:
> Hi,
> Just FYI, in the ODBC page there are several broken links to images.
> I've been testing other paths to the pics, but I don't know even if
> they are still in the HD:
> http://gambaswiki.org/wiki/doc/odbc
> Any chance to get it fixed?
> (Beware of cached content)
> Thanks!
> Jesús Guardon
--
zxMarce.
More information about the User
mailing list