Your DesktopX Documentation Resource Guide

Documentation Home

Quick Start

User's Guide

Developer's Guide

Resources

Tutorials


Database Access - PART 7:
I am working on something that will require access to a local (on the hard drive) database.
I do a LOT of ASP work on web sites, and was hoping that there would be some carry over.
I believe the DX code is about 3-4 lines different than the ASP (web page) code.

This will be a VERY short tutorial, its more like an article but I want this to be around for future people.
I will add more later if I can.

Text object / DB Access:
  Local database is on my D drive under TEMP, i want to access the TABLE in it called "Hooked Up"
Be aware this is a TEST I pulled a db from a web site i have running just to verify this works.

I'm not uploading anything for this, its just some code examples


Creating the Objects:
  We will make a TEXT object and put the DB access code into the On Start.

LOAD DekstopX and go into the CREATE mode:
* if you do not have DekstopX (builder) you will need to download it.
TEST OBJECT:
  Create the BASE object by
 

RIGHT-CLICK on the DekstopX Icon in the system tray.

Select "New object"

<-- See this for more info

 

The Object Properties Dialog will show up.

Click the "States" Tab

Change to "TEXT"

Type in something for the text

Set the font to whatever you want.

hit APPLY

 

Click the "Summary" tab

Set the width to 400-500

it keeps the text from going off the edge of the screen.

Hit Apply

 

Click on the "GENERAL" tab.

Click on "NEW" for the script

the window like this will load.

 

The Script:

  The Code for this little bit we are doing is VERY simple.
 
'-- The OnScriptEnter is executed when the object is loaded
Sub Object_OnScriptEnter
  object.Text = ""  ' Clear the text in the object
Set MyConn = CreateObject("ADODB.Connection")
' Create the connection to the DB COM
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\database.mdb"
' Connect to the DB FILE
Set RS = MyConn.Execute("SELECT * FROM HookedUp")
' Read the TABLE "HookedUp"
rs.movefirst
' Move to the first record in the table

While Not RS.EOF
' LOOP until the end of the table is reached
  For Each x In rs.fields    'Loop through the fields in the table
     object.text = object.text & x.name & ": " & x.value & vbnewline 
'Make the object's text show the field name & value
Next
'Loop through the fields
object.text = object.text & vbnewline
'add an extra line between each record
  RS.MoveNext 'Move to the next record

Wend 'end the loop
MyConn.Close
'Close the DB connection

End Sub 'Exit Sub

Click the "File" menu item, then "Save and Close editor", then click "OK" in the properties dialog box.

That's it, the db will be read when you save this and the info displayed in the object.

Again, this is just a "Proof of concept" that shows that you can access a Microsoft DB with DX, and actually VERY easily too!!


7/29 

SkinStudio 6.2 Released

7/25 

A God Has Fallen - New Demigod Trailer Released

7/24 

Sins of a Solar Empire v1.1 Beta has Arrived

7/23 

Stardock Releases New WindowBlinds 6.2 Update

7/22 

Stardock Releases The Political Machine v1.04 with New Characters

7/22 

Stardock Releases MyColors 2.5

7/17 

DesktopX 3.5 Officially Released

7/11 

Corel WinDVD 9 and Painter X Now Available on Impulse!