[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Transfer data from Sql Server 2005 to Adobe Flex 2.0 as xml

Posted on 2007-08-11
6
Medium Priority
?
1,158 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:DILORENZO
  • 2
  • 2
5 Comments
 
LVL 58

Expert Comment

by:amit_g
ID: 19677446
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.
0
 

Author Comment

by:DILORENZO
ID: 19677469
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.
0
 
LVL 58

Expert Comment

by:amit_g
ID: 19677476
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?
0
 

Author Comment

by:DILORENZO
ID: 19677516
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
0
 
LVL 1

Accepted Solution

by:
Vee_Mod earned 0 total points
ID: 19706863
Closed, 125 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This video teaches users how to migrate an existing Wordpress website to a new domain.

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question