Page 1 of 1
Connecting to SQL Express (localdb)\v11
Posted: Sun Jul 21, 2019 5:24 pm
by n.allan
Does anyone if livecode can connect to an SQL Express Server with the revOpenDatabase() function?
By it's nature the server is on the local machine (SQL Express does not allow remote connections)
I have tried...
Code: Select all
get revOpenDatabase("mysql", "localhost", "(localdb)\v11",,,,,,)
get revOpenDatabase("mysql", "127.0.0.1", "(localdb)\v11",,,,,,)
I'm not sure if SQL Express is even compatible with mysql parameter to be honest as databases are new territory for me.
I thought I would ask first before digging deeper.
I have also though about creating an ODBC connection to the SQL Express (localdb)\v11but I can't seem to filter through the mountains of drivel and adverts coming up on Google these days.
Re: Connecting to SQL Express (localdb)\v11
Posted: Sun Jul 21, 2019 6:05 pm
by SparkOut
Not sure about your OS, but for Windows, a file DSN may have a problem, but you might try odbc with a system DSN.
See this old post
viewtopic.php?f=12&t=31915&p=174414&hil ... sn#p174414 with links to even older posts, but should still be relevant
Re: Connecting to SQL Express (localdb)\v11
Posted: Sun Jul 21, 2019 7:04 pm
by n.allan
I have used file DSN in the past now you mention it. I could maybe create a file DSN to the mdf files that are created by SQL Express perhaps?
I dug out this old code for creating a ODBC DSN in windows from an mdb file livecode...
Code: Select all
function createConnection theFile
replace "/" with "\\" in theFile
if "\\" is not in theFile then replace "\" with "\\" in theFile
local regResult
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\Database\Driver","C:\\WINDOWS\\system32\\odbcjt32.dll")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\Database\DBQ",theFile)
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\DriverId",binaryEncode("I",0),"dword")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\FIL","MS Access;")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\SafeTransactions",binaryEncode("I",0),"dword")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\UID","")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\Engines\Jet\ImplicitCommitSync","")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\Engines\Jet\MaxBufferSize",binaryEncode("I",2048),"dword")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\Engines\Jet\PageTimeout",binaryEncode("I",5),"dword")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\Engines\Jet\Threads",binaryEncode("I",3),"dword")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ Database\Engines\Jet\UserCommitSync","Yes")
get setRegistry("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources\ Database","Microsoft Access Driver (*.mdb)")
if gConnectionID is number then
revCloseDatabase(gConnectionID)
put empty into gConnectionID
end if
get revOpenDatabase("odbc","Database", , , ,)
return it
end createConnection
I might try modifying this to read the mdf
Re: Connecting to SQL Express (localdb)\v11
Posted: Tue Jul 30, 2019 8:36 pm
by n.allan
OK no joy with the file DSN or indeed the system DSN....
More research required.