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: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

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

Post by AndyP »

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: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut »

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: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Post by AndyP »

Thanks SparkOut, once again you come to my rescue.
AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Post by AndyP »

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: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG »

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: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut »

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: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Post by AndyP »

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 .... LC CLASSIC ROCKS!
AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

EDITED 02/12/2008 14:42

Post by AndyP »

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 .... LC CLASSIC ROCKS!
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder »

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: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Post by AndyP »

Hi mwieder

No I haven't, will do now.
Andy .... LC CLASSIC ROCKS!
Post Reply