Setup an XML data connection which connects to a php, aspx, or other script in your favourite programming language. So, for example, set its URL to “www.website.com/script.php”
Turn on “Send Data” and send whatever data you want to add to the database to this script
The script itself will be pretty simple. In short:
a) Load the XML file from the http request (i.e., read the file that Xcelsius sent)
b) Parse the XML file into a string
c) Connect to your database and insert the string into it
I did for getting data out of databases with aspx, but not for writing back to the database - that’s beyond my capabilities!
But this question has been asked several times in the last 12 months and I’m almost certain somebody has covered it. This isn’t a particularly busy forum so it shouldn’t be too hard to find the posts.
Sorry to hijack this thread, but could you post or send me directly (contact details in my profile) a more comprehensive example of the aspx file with prompts? I’m looking to use a very similar solution for a client, so any help would be much appreciated.
for writeback the concept I used a few years back was:
I use a parameterised store procedure to insert the parameters into my database table.
I then have a derrived table based on the SPROC in my universe. Calling any element from the derrived table passes the SPROC parameters up from the database.
Anchor the parameters to fields in your Xcelsius model and call the SPROC execution in the connection manager on refresh of a trigger cell.
Associate the trigger cell with a push button, which you rename to Update or Ok and present like an input dialogue.
3.1 users can also use TaaWS if you can get past the really poor documentation and the fact it’s in Labs.
There’s a script on this forum. I pasted the whole thing a while back. Doesn’t have prompts though - I wouldn’t know how to do that. I just pass through user-selected values from xcelsius. And I’ve never done a write-back to a database.
Here’s the code with the variables bit added. No idea whether this is the best or most efficient way of doing stuff but it works for me…
The array passed in must be whatever you set as the output of your xcelsius connection.
Obviously in a real example you’d use avals(0) and avals(1) in the SQL:
"where something = '" & avals(0) & "' "
Note the single quotes concatenated either side.
Debbie
<% Response.CacheControl = "no-cache" %>
<% Response.Expires = -1 %>
<%@ Page Language="VB" aspcompat=true Debug="true" validateRequest="false" %>
<%
'----get user value output from xcelsius if required
Dim sXMLString
dim item as String
For Each item In Request.Form
sXMLString = sXMLString & item & " = " & Request.Form(item)
Next
Dim oXML as Object
Dim oNodeList as Object
Dim oNode as Object
oXML = Server.CreateObject( "Microsoft.XMLDOM" )
oXML.async = False
oXML.validateOnParse = False
oXML.loadXML(sXMLString)
dim sPath as String
sPath = "/data/variable/row/column"
oNodeList = oXML.documentElement.selectNodes(sPath)
dim i, aVals(1) '2 items passed out from xcelsius into a 2D array (0,1)
i=0
For Each oNode in oNodeList
With oNode
aVals(i)=.text
i=i+1
End With
Next
'----create a database connection & open it - oracle & sql server connection strings
dim oCon as object
oCon = Server.CreateObject("ADODB.Connection")
oCon.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=database;User Id=yyy;Password=zzz;"
'oCon.ConnectionString = "Provider=SQLOLEDB;Data Source=path;Initial Catalog=database;User Id=yyy;Password=zzz; "
oCon.Open
'----create a recordset & open it
dim oRst as object
oRst = Server.CreateObject("ADODB.RecordSet")
oRst.ActiveConnection = oCon
dim sSQL as String
sSQL = sSQL & " select sysdate from dual "
oRst.Open(sSQL)
'----output results as xml
dim str as string
str = oRst.GetString(,,"</row><row>","</row></column><column><row>","&nbsp;")
dim sXML as string
sXML = "<data>" + chr(13)
sXML = sXML + " <variable name=" + chr(34) + "Range0" + chr(34) + ">" + chr(13)
sXML = sXML + str + Chr(13)
sXML = sXML + " </variable>" + chr(13)
sXML = sXML + "</data>"+ chr(13)
Response.Write(sXML)
'----close down
oRst.close
oRst = Nothing
oCon.close
oCon = Nothing
%>
Yes. By building the SQL as a string. In its simplest form
dim sSQL as String
sSQL = sSQL & " select columns from tables "
sSQL = sSQL & " where table.column = '" & avals(0) & "' and ... "
oRst.Open(sSQL)
Where avals(0) is one of the array values passed out from xcelsius. Sometimes I’ll process avals(0) further and end up with another variable in the SQL instead.
Sometimes even the FROM statement is a variable, so I might have:
dim sSQL as String
sSQL = sSQL & " select columns from " & tab_var & " "
sSQL = sSQL & " where table.column = '" & avals(0) & "' and ... "
oRst.Open(sSQL)
where tab_var could be any one of 3 or 4 different aggregate tables depending on what grain of data I’m looking at.