Livecode ODBC connection without DSN?

Dalton Calford dalton.calford at gmail.com
Wed Jul 3 11:54:17 EDT 2019


Thanks Bob, very helpful.

On Wed, 3 Jul 2019 at 11:42, Bob Sneidar via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Maybe a little more useful as a complete function:
>
> function dbConnectODBCByString pServer, pDatabase, pUser, pPasswd
>    switch the platform
>       case "MacOS"
>          get revOpenDatabase("ODBC","Driver={Actual SQLServer};Server=" &
> pServer & ";Database=pDataBase;UID=" & pUser & ";PWD= & pPasswd & ";",,,)
>          break
>       case "Win32"
>          put
> listregistry("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\") into
> tOdbcDrivers
>          switch
>             case "SQL Server Native Client 11.0" is in tOdbcDrivers
>                get revOpenDatabase("ODBC","DRIVER={SQL Server Native
> Client11.0};SERVER=" & pServer & ";DATABASE=pDataBase;UID=" & pUser &
> ";PWD=" & pPasswd & ";Trusted_Connection=No",,,)
>                break
>             case "SQL Server Native Client 10.0" is in tOdbcDrivers
>                get revOpenDatabase("ODBC","DRIVER={SQL Server Native
> Client10.0};SERVER=" & pServer & ";DATABASE=pDataBase;UID=" & pUser &
> ";PWD=" & pPasswd & ";Trusted_Connection=No",,,)
>                break
>             case "SQL Server" is in tOdbcDrivers
>                get revOpenDatabase("ODBC","DRIVER={SQLServer};SERVER=" &
> pServer & ";DATABASE=pDataBase;UID=" & pUser & ";PWD=" & pPasswd &
> ";Trusted_Connection=No",,,)
>                break
>          end switch
>          break
>    end switch
>    return it
> end dbConnectODBCByString
>
> Bob S
>
>
> > On Jul 3, 2019, at 08:22 , Dalton Calford via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> >
> > Wonderful!  Thanks Matthias!
> >
> > I can ensure the ODBC drivers are in, that is not an issue.   Most of my
> > testing will be for linux anyways.
> >
> > Best regards
> >
> > Dalton
> >
> >
> > On Wed, 3 Jul 2019 at 11:09, Matthias Rebbe via use-livecode <
> > use-livecode at lists.runrev.com> wrote:
> >
> >> Hi Dalton,
> >>
> >> yes it is. You can use SQL Connection strings for it. But in any case
> >> you´ll need to have ODBC drivers installed.
> >>
> >> This here is an old script i used to query the installed Windows ODBC
> >> drivers and do the connection with Connection strings.
> >> It´s old and was registry check was used under Windows 32bit. But the
> >> Connectionstrings still should do with one exception.
> >>
> >> This does not work with new versions of LC on Mac. The latest Mac
> version
> >> which worked with SQL Connection strings was 6.7.11.
> >> Here´s the bug report from 2016
> >> https://quality.livecode.com/show_bug.cgi?id=18151 <
> >> https://quality.livecode.com/show_bug.cgi?id=18151>
> >>
> >>
> >> And here´s the script
> >> -- connection strings Win/Mac with check which Windows SQL ODBC drivers
> >> are installed
> >>
> >> switch the platform
> >>
> >> case "MacOS"
> >>
> >> get revOpenDatabase("ODBC","Driver={Actual SQL
> >>
> Server};Server=192.168.1.250;Database=MyDatabaseName;UID=sa;PWD=MyDatabasePassword;",,,)
> >>
> >> break
> >>
> >> case "Win32"
> >>
> >> put listregistry("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\") into
> >> tOdbcDrivers
> >>
> >> switch
> >>
> >> case "SQL Server Native Client 11.0" is in tOdbcDrivers
> >>
> >> get revOpenDatabase("ODBC","DRIVER={SQL Server Native Client
> >>
> 11.0};SERVER=192.168.1.250;DATABASE=MyDatabaseName;UID=sa;PWD=MyDatabasePassword;Trusted_Connection=No",,,)
> >>
> >> break
> >>
> >> case "SQL Server Native Client 10.0" is in tOdbcDrivers
> >>
> >> get revOpenDatabase("ODBC","DRIVER={SQL Server Native Client
> >>
> 10.0};SERVER=192.168.1.250;DATABASE=MyDatabaseName;UID=sa;PWD=MyDatabasePassword;Trusted_Connection=No",,,)
> >>
> >> break
> >>
> >> case "SQL Server" is in tOdbcDrivers
> >>
> >> get revOpenDatabase("ODBC","DRIVER={SQL
> >>
> Server};SERVER=192.168.1.250;DATABASE=MyDatabaseName;UID=sa;PWD=MyDatabasePassword;Trusted_Connection=No",,,)
> >>
> >> break
> >>
> >> end switch
> >>
> >> break
> >>
> >> end switch
> >>
> >> Regards,
> >>
> >> Matthias
> >>
> >>
> >>
> >> Matthias Rebbe
> >>
> >> free tools for Livecoders:
> >> https://instamaker.dermattes.de <https://instamaker.dermattes.de/>
> >> https://winsignhelper.dermattes.de <https://winsignhelper.dermattes.de/
> >
> >>> Am 03.07.2019 um 16:42 schrieb Dalton Calford via use-livecode <
> >> use-livecode at lists.runrev.com <mailto:use-livecode at lists.runrev.com>>:
> >>>
> >>> Is it possible to connect to a database without a predefined DSN using
> >> the
> >>> livecode database connector?
> >>>
> >>> best regards
> >>>
> >>> Dalton
> >>> _______________________________________________
> >>> use-livecode mailing list
> >>> use-livecode at lists.runrev.com <mailto:use-livecode at lists.runrev.com>
> >>> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >>> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list