[Gambas-user] Gambas and MS SQL
Caveat
Gambas at ...1950...
Fri Oct 18 13:38:53 CEST 2013
Hi Ivan
[Hi Randall, you got there before me, but I think this is still useful
even if it is repeating stuff that may have appeared on the mailing list
before]
Yes, it's quite possible. There's a very good guide here:
http://ubuntuforums.org/showthread.php?t=1098688
It worked fine for me on Ubuntu... I just had to do:
> sudo apt-get install unixodbc unixodbc-dev freetds-dev sqsh tdsodbc
> sudo vi /etc/freetds/freetds.conf
and added an entry like:
[MSSQL_TRY]
host = www.myserver.com
port = 1433
tds version = 7.0
Then test the basic FreeTDS setup (obviously replace some_user and
some_pwd and some_dbname (and some_...) with an appropriate username,
password, dbname blah blah):
> sqsh -S MSSQL_TRY -U some_user -P some_pwd
1> use some_dbname
2> go
1> select top 1 some_column, some_other_column from some_table
2> go
1> quit
Next, as the guide says, configure odbc... you need to edit
/etc/odbcinst.ini and /etc/odbc.ini to look like this:
> cat /etc/odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
#Driver = /usr/lib/odbc/libtdsodbc.so
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
#Setup = /usr/lib/odbc/libtdsS.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
and this:
> cat /etc/odbc.ini
[MSSQL_TRY]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = MSSQL_TRY
Database = some_dbname
Note that, in my case (perhaps because of newer version or 64bit version
of Ubuntu, my .so files were in a different place in the odbcinst.ini file),
Now test in isql that everything is good (as per the guide):
isql -v MSSQL_TRY some_user some_password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from some_table
...
SQL> quit
Then, finally, in Gambas code something like:
With myDB
.Type = "odbc"
.Host = "MSSQL_TRY"
.Login = "some_user"
.Password = "some_password"
.Name = "some_dbname"
End With
Let me know if anyhting is not clear
Kind regards,
Caveat
On 18/10/13 10:47, Ivan Kern wrote:
> Hello.
>
>
>
> Does somebody use Gambas for communication with MS SQL database?
>
> Is it possible with ODBC?
>
>
>
> Best regards,
>
>
>
> Ivan
>
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list