[Gambas-user] Connection via ODBC
First Last
d4t4full at gmail.com
Mon Oct 19 19:34:02 CEST 2020
(Sorry for the "mailus interruptus", I'll start over.)
In *this link*
<https://www.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.cli.doc/doc/t0006349.html>
you'll find info about setting up the whole DB2 under ODBC environment for
Linux/Unix, courtesy of IBM.
Note that since Aug 2015, though, there are two ways to set up pretty much
*any* database using ODBC in Gambas.
The first one is setting up the whole unixODBC Driver Manager environment
as above described and normally used, but it takes time, is kind of
error-prone and tiresome if you have to deploy the same app to a bunch of
end users (same setup over and over...).
The second approach I tried to assimilate as smoothly as possible to
whatever already existed, and is similar to what exists on Windows
platforms, and it is the use of "Connection Strings".
Basically, you tell ODBC all the settings that normally go in the several
ODBC config files in a single string, and the ODBC Driver Manager will take
care of the connection.
This is an example Connection String for connecting to a MSSQL Server 2005
using freeTDS from ODBC
*"Driver=FreeTDS;TDS_Version=7.2;Server={serverIP};Port=1433;Database={databaseName};UId={userName};Password={password}"*
In Gambas, you'd connect this way:
*' Gambas class file*
*Private $conn As Connection*
*'[...]*
*Private Sub Connect(connString As String)*
* $conn = New Connection*
* $conn.Type = "odbc" 'Yup, lowercase.*
* $conn.Host = connString*
* $conn.Open()*
*End*
You just call Connect() with the adequate connection string.
Now, parameters for the vast amount of different drivers depend on the
actual driver used by ODBC (unfortunately, I don't have access to anything
besides MSSQL), as an example, the *TDS_Version* parameter in the example
above sets some defaults in FreeTDS so it knows "beforehand" to what kind
of server it will connect.
Beware: Some parameters may, others WILL, affect connectivity and may also
impact overall speed.
HTH,
zxMarce.
On Mon, Oct 19, 2020 at 2:18 PM First Last <d4t4full at gmail.com> wrote:
> Gianluigi,
>
> In *this link*
> <https://www.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.cli.doc/doc/t0006349.html>
> you'll find info about setting up the whole DB2 under ODBC environment for
> Linux/Unix, courtesy of IBM.
> Note that since Aug 2015, though, there are two ways to set up pretty much
> *any* database using ODBC in Gambas.
> The first one is setting up the whole unixODBC Driver Manager environment
> as above described and normally used, but it takes time, is kind of
> error-prone and tiresome if you have to deploy the same app to a bunch of
> end users (same setup over and over...).
>
> The second approach I tried to assimilate as smoothly as possible to
> whatever already existed, and is similar to a
>
>
>
> On Mon, Oct 19, 2020 at 12:03 PM Gianluigi <bagonergi at gmail.com> wrote:
>
>> An Italian friend of ours asks if anyone knows how to connect Gambas to a
>> DB2 database through the ODBC driver, thanks.
>>
>> Regards
>> Gianluigi
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201019/dbaa459e/attachment.htm>
More information about the User
mailing list