Fuente : Foro www.linuxbasic.net -> Foro gambas
Escrito : October 02, 2008, 05:04:50 pm by fredwarren
There are two ways to do this, graphically and by the command line. I will walk through the command line. Having done it that way I could now figure out the GUI way to do this. In my sample we are going to use a database named Mickey on the server Donald. With Ubuntu Hardy we need to:
Install unixodbc tdsodbc, and libct3
sudo apt-get install unixodbc tdsodbc libct3
Configure the database in freetds by editing /etc/freetds/freetds.conf
[Test]
host = DONALD
tds version = 8.0
Configure unixodbc to recognize freetds by editing /etc/odbcinst.ini
[FreeTDS]
Description - TDS driver (Sysbase/MS SQL)
Driver = /usr/lib/odbc/libstdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout = 5
CPResue = 5
Configure odbc to use the freetds database.by editing /etc/odbc.ini
[Test]
Description = Test Connection to DONALD
Driver = FreeTDS
Servername = Test
Database = Mickey
Note that that Servername in /etc/odbc.ini is the same as the bracketed section title in /etc/freetds/freetds.conf. In our case this means Servername = Test and in freedtds.conf [Test]. The test in /etc/odbc.ini is the same as in the .Host = "Test" in the
gambas sample below.
And here is the code I used in
gambas
DIM $hConn AS NEW Connection
WITH $hConn
.Type = "odbc"
.Host = "Test"
.Login = "your-username"
.Password = "your-password"
END WITH
$hConn.Open
IF ($hConn.Opened = FALSE)
Message.Error("Error Opening the connection")
PRINT $hConn.Error
ELSE
Message.Info("This really Works")
ENDIF
Saludos.
pd: GIYF (Google Is Your Friend)