[Gambas-devel] Change to gb.db.odbc to use ODBC Connection Strings.

Benoît Minisini gambas at ...1...
Wed Aug 26 01:01:49 CEST 2015

Le 19/08/2015 20:20, zxmarce a écrit :
> Hi guys, first devel post.
> For some time now I needed to be able to use connection strings (à-la MS) in
> the *ODBC* component for connecting to DB Servers. In ODBC parlance, I need
> to use *DSN-less* connections.
> When this all started, I used only packaged Gambas binaries, and knew just a
> bit of C and nothing about Linux. I still do, but I gained some self-trust
> in C and also started tinkering with C unixODBC examples in the 'Net. I even
> made a Gambas3 class to connect using EXTERN calls to *libodbc* to see if
> connection with ConnStrings is possible: It is!
> There are two main issues with this approach:
> 1- My class cannot create and manipulate G3 database objects at low level.
> 2- Given problem 1 above, any existing DB-access program should be remade
> since there's no back-compatibility due to not being able to use native G3
> DB components.
> All this made me look at the *gb.db.odbc* C sources. I downloaded them and
> added an IF and a Function.
> My modified component source calls my new internal function (*static bool
> is_host_a_connstring(char *host_or_cs)*) in order to see if the *.Host
> *property of the *Connection* object is a Host name (no embedded "*;*" or
> "*=*"), or a Connection String (has embedded "*;*" and/or "*=*"). Based on
> the outcome of the function, it calls *SQLConnect* (when a Host) as before,
> or *SQLDriverConnect* (when a ConnString). Those are the only changes, but
> more changes MAY be necessary, I do not really know. That was the only place
> where the component seems to use an ODBC connect call.
> My additions/changes were tested successfully in a C example that used
> SQLConnect which I turned interactive and can now connect to a DSN or using
> a DSN-less, ConnectionString-based approach.
> Now that I have the "new" *gb.db.odbc* component sources, I need three
> things:
> 1- How to compile -if possible- just my ODBC component modified.
> 2- Once compiled, where to install it so G3 can use it, having backed up the
> older one just in case. I have both, 32 and 64 bit Ubuntu 14.04 systems
> available for testing.
> 3- If my tests after compiling and using go OK, whom/where should I send the
> sources for further test and inclusion in the main G3 sources?
> TIA,
> zxMarce.


Sorry for the delayed answer, the new Gambas bugtracker was a bit urgent...

For a small change, just send a patch to the dev. mailing-list, or the 
modified file. The driver is just one source file, so I can check & 
merge the change for you.

Otherwise, generally, you must:
- Use subversion.
- Create a sourceforge account.
- Ask me for a write access to the repository.
- Checkout a local copy of the Gambas source tree.
- Remove all other installation of Gambas from your system.
- Do your changes in it, and do all the configuration / compilation / 
installation stuff in it. You are using the "development version" of 
Gambas now.
- Once everything works, you commit your changes. Everybody else can 
access them, and it will be inserted in the next major release of Gambas.


Benoît Minisini

More information about the Devel mailing list