DILORENZO
asked on
Transfer data from Sql Server 2005 to Adobe Flex 2.0 as xml
Why is Adobe Flex 2.o giving me the error "The markup in the document precending the root element must be well-formed" when trying to load xml via an .aspx script produced string, yet it works if I save the string as a .xml?
I am calling the script in Flex as such
<mx:XML id="treeData" source="bin\xml\user_list. aspx" />
THis is my .aspx
__________________________ __________ __________ __________
<?xml version="1.0" encoding="iso-8859-1"?>
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data.Sql Client" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%
Response.Cache.SetExpires( DateTime.N ow.AddSeco nds(1))
Dim ConnString as String = "------------------------- ---------- --"
' get users from database
Dim userConn As New SqlConnection( ConnString )
userConn.Open()
Dim userSQL as String = "SELECT * FROM userAccounts ORDER by last_name ASC;"
Dim userCommand As New SqlCommand(userSQL, userConn)
Dim userDataReader As SqlDataReader = userCommand.ExecuteReader
Dim dataOutPut as String = ""
dataOutPut += "<nodeTop>"
While userDataReader.Read() ' read move count forward by one, returns false if next one does not exist
'WHILE groupCount < 10
dataOutPut += "<node label='" & userDataReader("user_name" ) & "'>"
dataOutPut += "<node user_name='" & userDataReader("user_name" ) & "'/>"
dataOutPut += "</node>"
End While
userDataReader.Close()
userConn.Close()
dataOutPut += "</nodeTop>"
response.write(dataOutPut)
%>
__________________________ __________ __________ _
I really just need to know the best way to share data between Flex and SQL Server without resorting to web or data services. I want to do it strickly through scripts or if sql server has something better im all ears. Thanks
I am calling the script in Flex as such
<mx:XML id="treeData" source="bin\xml\user_list.
THis is my .aspx
__________________________
<?xml version="1.0" encoding="iso-8859-1"?>
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data.Sql
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%
Response.Cache.SetExpires(
Dim ConnString as String = "-------------------------
' get users from database
Dim userConn As New SqlConnection( ConnString )
userConn.Open()
Dim userSQL as String = "SELECT * FROM userAccounts ORDER by last_name ASC;"
Dim userCommand As New SqlCommand(userSQL, userConn)
Dim userDataReader As SqlDataReader = userCommand.ExecuteReader
Dim dataOutPut as String = ""
dataOutPut += "<nodeTop>"
While userDataReader.Read() ' read move count forward by one, returns false if next one does not exist
'WHILE groupCount < 10
dataOutPut += "<node label='" & userDataReader("user_name"
dataOutPut += "<node user_name='" & userDataReader("user_name"
dataOutPut += "</node>"
End While
userDataReader.Close()
userConn.Close()
dataOutPut += "</nodeTop>"
response.write(dataOutPut)
%>
__________________________
I really just need to know the best way to share data between Flex and SQL Server without resorting to web or data services. I want to do it strickly through scripts or if sql server has something better im all ears. Thanks
ASKER
I still get the same results. Im pulling my hair out here because I use to have this application working fine. I just got a new computer and setting everything up like my old on has been a nightmare.
I don't know how Adobe Flex works but some browsers cache the ContentType and need a restart. Is there something like that in Adobe Flex?
ASKER
I can not believe I spent hours on this.
The reference...
<mx:XML id="treeData" source="bin/xml/menu.aspx" />
Should have been..
<mx:XML id="treeData" source="http://localhost/xml/menu.aspx" />
It has to be absolute rather than relative. That is a kick in the pants. Thank you for your help
The reference...
<mx:XML id="treeData" source="bin/xml/menu.aspx"
Should have been..
<mx:XML id="treeData" source="http://localhost/xml/menu.aspx" />
It has to be absolute rather than relative. That is a kick in the pants. Thank you for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Response.ContentType = "text/xml"
before Response.Cache line and try it again.