Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 5:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Please help me setup and use an Access Database Connection?
PostPosted: March 3rd, 2008, 10:46 pm 
Offline

Joined: March 21st, 2006, 10:37 pm
Posts: 31
Location: Grantham, Lincolnshire,UK
Hello, I am struggling a bit with an access database.

I have created a database in access with two tables, Match and Scoreboard.

The datasourcename I have specified exists. How would I make the DSN path always refer to the publication root directory?

I have this code in a script file which is called when the page opens.

[code]English01.Show()




var dataSourcePath = "FILEDSN=C:\Documents and Settings\Administrator\My Documents\Dunix\Projects\Zai\MatchingGame\Opus Project\Database\MatchingGameDataSource.dsn;"

var matchDatabase = new Database(dataSourcePath)


if (matchDatabase.Connect())
{


English03.Show()


var results = matchDatabase.ExecuteSQL("SELECT * Match")


English04.Show()

English04.SetText("Test")

}[/code]


The connection fails and none of the other text boxes get shown (English0x.Show()).

Am I doing the connection correctly?

Also, how do I change the text value of a text box?

And finally, how do I read the data I pulled back data from the database? I have gone through all the manual and I cannot see how.

I would prefer to code everything myself in script objects.


Top
 Profile  
 
 Post subject:
PostPosted: March 4th, 2008, 11:44 pm 
Offline

Joined: March 21st, 2006, 10:37 pm
Posts: 31
Location: Grantham, Lincolnshire,UK
Anyone?


Top
 Profile  
 
 Post subject:
PostPosted: March 4th, 2008, 11:50 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
Look at the last five tutorials on this page.

viewforum.php?f=13

Paul


Top
 Profile  
 
 Post subject:
PostPosted: March 6th, 2008, 8:42 am 
Offline

Joined: March 21st, 2006, 10:37 pm
Posts: 31
Location: Grantham, Lincolnshire,UK
So you cant do it through scripting entirely then? My aim is to pull back the data, loop through it and put it into an array. Then randomly select records from the array.


Top
 Profile  
 
 Post subject:
PostPosted: March 11th, 2008, 11:19 pm 
Offline

Joined: March 21st, 2006, 10:37 pm
Posts: 31
Location: Grantham, Lincolnshire,UK
Anyone?


Top
 Profile  
 
 Post subject:
PostPosted: March 12th, 2008, 7:42 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Yes you can script the whole thing.

Use the instructions in the database section (functions) of the manual. It explains how to connect, create a loop (GetNumberOfRecords()) and then you read these into an array.

Use the random number function (max records) to pick a random record. There is also lots of example already posted on the forum for scripted DBs.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 12th, 2008, 12:58 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
zes,

Try reworking this part a bit.
Quote:
var dataSourcePath = "FILEDSN=C:\Documents and Settings\Administrator\My Documents\Dunix\Projects\Zai\MatchingGame\Opus Project\Database\MatchingGameDataSource.dsn;"

var matchDatabase = new Database(dataSourcePath)


if (matchDatabase.Connect())
{


Some general observations.

1- most times I see that paths in Opus require \\ to represent the usual \ when in a string.
2- var dataSourcePath --- I've had trouble with putting expressions in strings. Sometimes I've had to break them down and then use the eval() command... which is a great tool, but I found tricky to master.
3- isn't the var 'matchDatabase' an object? Then, does the if statement operate correctly? Testing for an object? Maybe make it more explicit, e.g. == true, or verify it exists?

If you're following the manual and a good sample script on databases in Opus, then my comments may not apply.

p.s. Are you using Vista?
The path shown about would indicate you are running on WinXP or such.

_________________
_good things come to those who wait(0)_


Top
 Profile  
 
 Post subject:
PostPosted: March 12th, 2008, 10:06 pm 
Offline

Joined: March 4th, 2007, 7:17 pm
Posts: 132
Code:
var results = matchDatabase.ExecuteSQL("SELECT * Match")

maybe little mistake: ExecuteSQL("SELECT * FROM Match")


zesmail, write about your successes, I have similar problems:)


Top
 Profile  
 
 Post subject:
PostPosted: March 12th, 2008, 11:22 pm 
Offline

Joined: March 21st, 2006, 10:37 pm
Posts: 31
Location: Grantham, Lincolnshire,UK
Yes, I did forget the FROM statement. I had actually fixed that bit a while ago. The issue was actually using "\" instead of "\\". Once I used "\\" instead it all started working nicely!

Thanks for everyones help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group