Using a File DSN EDITED 02/12/2008 14:42

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Using a File DSN EDITED 02/12/2008 14:42

Post by AndyP » Wed Nov 19, 2008 6:01 pm

Is it possible to connect to an Access db using a file dsn?

I've done this before with other development software but cannot see how to acheive in Revolution.

File DSN example below.

[ODBC]
DRIVER=Microsoft Access Driver (*.mdb)
UID=admin
UserCommitSync=no
Threads=3
SafeTransactions=0
PageTimeout=5
MaxScanRows=8
MaxBufferSize=2048
FIL=MS Access
DriverId=25
DefaultDir=C:\mydb\
DBQ=C:\mydb\mydb.mdb
Last edited by AndyP on Tue Dec 02, 2008 3:44 pm, edited 4 times in total.

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

Post by SparkOut » Wed Nov 19, 2008 6:13 pm

In theory:

Code: Select all

get revOpenDatabase("odbc","theDSNfile",,"admin","adminpassword","cursortype")
Note the empty item between theDSNfile and username.
Rev dictionary wrote:To use a DSN to identify an ODBC database, use the DSN as the host, and leave the databaseName parameter empty.

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Post by AndyP » Thu Nov 20, 2008 1:33 pm

Thanks SparkOut, once again you come to my rescue.

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Post by AndyP » Fri Nov 21, 2008 5:39 pm

Well got ahead of myself there...have removed the --Solved --

How do I get the DSN info in here? (thebit in bold)

revOpenDatabase("odbc","theDSNfile",,"admin","adminpassword","cursortype")

I tried just putting the file location in but this did not work. :oops:

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Post by BvG » Sat Nov 22, 2008 2:23 pm

I don't know much about databases, and nothing about dsn files. Said that, if you need to give rev the data within the file, maybe you should load it into memory first, then give that to the revOpenDatabase function:

Code: Select all

put url "file:path/to/dsnfile" into theDSN
get revOpenDatabase("odbc",theDSN,,"admin","adminpassword","cursortype")
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

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

Post by SparkOut » Sun Nov 23, 2008 12:28 pm

Hmmm, well I said "in theory" ;)

And in theory, using the path to the DSN file should be correct - I don't think you have to load the contents.

I did some testing and I cannot make a File DSN work. I get an error:

[Microsoft][ODBC Driver Manager]Invalid string or buffer length

If I change the File DSN to a System DSN and just use the name of the System DSN, then I get a connection OK.

(You might have to work to stop it barfing on paths and/or table names with spaces in)

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Post by AndyP » Tue Nov 25, 2008 10:08 pm

Thanks SparkOut, BVG,
I will have a play with the paths etc and if I find a usable solution post it back here for reference.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

EDITED 02/12/2008 14:42

Post by AndyP » Tue Dec 02, 2008 1:01 pm

OK, I think I've exhausted all permatations and have come to the conclusion that FileDSN will not work with the ODBC Revolution dll (dbodbc.dll)

It's a shame because using a FileDSN is an easy way to add connectivity to an Access db, you need to just deploy the FileDSN file with the application.

Anyway moving on, what I've decided to do is to create a System DSN on the clients computer using writes to the registry. I'm going to post an article and example on how to do this later today in the 'Databases' section of the forums.

Posting is here:

EDITED 02/12/2008 14:42

http://forums.runrev.com/phpBB2/viewtopic.php?t=2441
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Sat Dec 06, 2008 2:35 am

Andy- thanks for doing the legwork on this. I think you're right - FileDSN seems broken in rev's driver. Have you filed a bug report on this?

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Post by AndyP » Mon Dec 08, 2008 2:10 pm

Hi mwieder

No I haven't, will do now.
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”