[Gambas-user] Connection via ODBC

Gianluigi bagonergi at gmail.com
Mon Oct 19 19:44:03 CEST 2020


Il giorno lun 19 ott 2020 alle ore 19:35 First Last <d4t4full at gmail.com> ha
scritto:

> (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.
>

Hi,

thank you very much, I pass the information to our friend immediately...

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201019/89beceed/attachment-0001.htm>


More information about the User mailing list