A list of products available on this site
Documentation for XtraMania's xtras
Prices and links to the online store
Xtras, PDFs, samples
Have a question? Ask us!
Contacts
Logo. www.xtramaina.com  
Home Search E-mail
ADOxtra_MUS Reference

Make it running

Server-side

Make sure you have placed ADOxtra_MUS.x32 into Xtras folder of your MUS installation.

Add ADOxtra to ServerExtensionXtras list in Multiuser.cfg. It should look like:
ServerExtensionXtras = RuntimeAttributes DatabaseObjects LingoVM ADOxtra

Place configuration commands for ADOxtra into your Multiuser.cfg. It should be something like:
XtraConfigCommands for ADOxtra

XtraCommand = "QueryParamStart: <%"
XtraCommand = "QueryParamEnd: %>"

# Here we create a DataSource with name: TestDB
XtraCommand = "DataSource: TestDB"

#Allow it to be used from client
XtraCommand = "AccessMode: Normal"
# XtraCommand = "AccessMode: Limit to server-side"

#ADO Connection string for the data source
XtraCommand = "ADO.ConnectionString: Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Databases\TestDB.mdb"

#Open it right now
XtraCommand = "ADO.Open"

#Here we create a Query object with name TestQuery
XtraCommand = "Query: TestQuery"

#Make it available to MUS client movies
XtraCommand = "AccessMode: Normal"
# XtraCommand = "AccessMode: Limit to server-side"

#We do not usually want clients to be able to overwrite the SQL of this object
XtraCommand = "UseSQL: Predefined"
#XtraCommand = "UseSQL: Any"

#Define SQL query with formal parameter ParentId
XtraCommand = "ADO.SQL: SELECT * FROM Structure WHERE ParentId=<%ParentId%>"

#Use static cursor for the recordset
XtraCommand = "ADO.CursorType: adOpenStatic"
# XtraCommand = "ADO.CursorType: adOpenDynamic"
# XtraCommand = "ADO.CursorType: adOpenForwardOnly"
# XtraCommand = "ADO.CursorType: adOpenKeyset"

#Use ADO client cursor
XtraCommand = "ADO.CursorLocation: adUseClient"
# XtraCommand = "ADO.CursorLocation: adUseServer"

#Put a read only lock
XtraCommand = "ADO.LockType: adLockReadOnly"
# XtraCommand = "ADO.LockType: adLockPessimistic"
# XtraCommand = "ADO.LockType: adLockOptimistic"
# XtraCommand = "ADO.LockType: adLockBatchOptimistic"

#Set ADO cache size for the recordset
XtraCommand = "ADO.CacheSize: 10"

#We could open recordset here but there is no need to do it now
# XtraCommand = "ADO.Open"

You will need to edit lines above to set the correct path to your database file in the connection string and to make an appropriate SQL query.

Run the MUS and make sure ADOxtra proccesses all commands you entered.

Client side

Now create a new test movie in Director. You will need a parent script that would handle network messages. Create a parent script similar to:
-- Net messages handler
on new me
  return me
end

on NetMessageHandler
  global mus
  newMessage = mus.getNetMessage()
  put newMessage
  if newMessage.errorCode 0 then
    put "Error: " & moaErrorToString(newMessage.errorCode)
  end if
end

Name it: "NetHandler". Then type the statements below in messages window:
-- Create a MUS connection instance
mus = xtra("multiuser").new()

-- Set the handler for it
put mus.setNetMessageHandler(#NetMessageHandler, script("NetHandler").new())
-- It should return 0

-- Connect it to your server
mus.connectToNetServer("user", "", "IP or computer name",1626,"Test")
-- It should return 0

-- After connecting your handler script should put in Messages something like:
-- [#errorCode: 0, #recipients: ["user"], #senderID: "System", #subject: "ConnectToNetServer", #content: , #timeStamp: 0]

-- Now you can get some data:
put mus.sendNetMessage( "System.ADO.GetData", "TestDB.TestQuery", [#QueryParams:[#ParentId:1]], 0 )

Handler should put something like:
-- [#errorCode: 0, #recipients: ["eugene"], #senderID: "System.ADO.GetData", #subject: "TestDB.TestQuery", #content: [#DataReloaded: 1, #data: [[],[],[...etc]]], #timeStamp: 6374249]

Note the #Content property that contains data returned by ADO in a form of list of records.

Site homeSearchContact author © Eugene Shoustrov. www.xtramania.com