Link to home
Start Free TrialLog in
Avatar of DILORENZO
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.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%

Response.Cache.SetExpires(DateTime.Now.AddSeconds(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
Avatar of amit_g
amit_g
Flag of United States of America image

Even though you are producing the correct xml the content type would still be text/html. Adobe Flex might be expecting text/xml. So add

Response.ContentType = "text/xml"

before Response.Cache line and try it again.
Avatar of DILORENZO
DILORENZO

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?
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
ASKER CERTIFIED SOLUTION
Avatar of Vee_Mod
Vee_Mod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial