Autore Topic: Gambas e MS SQL  (Letto 979 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.719
  • Ne mors quidem nos iunget
    • Mostra profilo
Gambas e MS SQL
« il: 18 Ottobre 2013, 17:52:13 »
Vi riporto questa discussione apparsa nell M.L. ufficiale:


" Does somebody use Gambas for communication with MS SQL database?

Is it possible with ODBC?

Ivan
"


" This question was asked a few months ago. so you might want to search the list archive.

You might also want to look at: This question was asked a few months ago.
It is also possible to write a simple client on the Windows db server and
link to it over the network.
http://www.easysoft.com/products/data_access/odbc-sql-server-driver/getting-started.html
Back around 2000 there was a Windows Networking programming book I read that had code for a nice starting point.
There are many ways to do this and it depends on your needs as to how to accomplish it.

Randall Morgan
"


" 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:

 
Codice: gambas [Seleziona]
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
"
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »