Connecting to SQL Express (localdb)\v11

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 130
Joined: Mon Mar 12, 2007 12:06 pm

Connecting to SQL Express (localdb)\v11

Post by n.allan » Sun Jul 21, 2019 5:24 pm

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.

SparkOut
Posts: 2084
Joined: Sun Sep 23, 2007 4:58 pm

Re: Connecting to SQL Express (localdb)\v11

Post by SparkOut » Sun Jul 21, 2019 6:05 pm

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

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 130
Joined: Mon Mar 12, 2007 12:06 pm

Re: Connecting to SQL Express (localdb)\v11

Post by n.allan » Sun Jul 21, 2019 7:04 pm

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

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 130
Joined: Mon Mar 12, 2007 12:06 pm

Re: Connecting to SQL Express (localdb)\v11

Post by n.allan » Tue Jul 30, 2019 8:36 pm

OK no joy with the file DSN or indeed the system DSN....
More research required.

Post Reply

Return to “Databases”