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

zxmarce d4t4full at ...176...
Wed Aug 19 20:20:45 CEST 2015


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.



--
View this message in context: http://gambas.8142.n7.nabble.com/Change-to-gb-db-odbc-to-use-ODBC-Connection-Strings-tp52283.html
Sent from the gambas-devel mailing list archive at Nabble.com.




More information about the Devel mailing list