I’m trying to use ASP.NET to retrieve data from the sql server, place in inside an xml and sends the xml to flash to display the data.
I’m getting
TypeError: Error #1088: The markup in the document following the root element must be well-formed.
at news_fla::mainTimeline/loaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
This is my code:
ASP.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim adapter As SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
Dim con As New SqlConnection("data source = GN80000798-0\SQLEXPRESS2008; initial catalog = EL; integrated security = true")
sql = "select * from news"
Try
con.Open()
adapter = New SqlDataAdapter(sql, con)
adapter.Fill(ds, "data")
con.Close()
Response.ContentType = "text/XML"
Response.HeaderEncoding = Encoding.UTF8
ds.WriteXml(Response.OutputStream, XmlWriteMode.WriteSchema)
MsgBox("Done")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Flash
import flash.xml.*;
var newsrequest:URLRequest = new URLRequest(“http://localhost:1179/DB/DB.aspx”); //ASP.NET development server
var newsloader:URLLoader = new URLLoader();
var newsxml:XML;
var dvar:URLVariables = new URLVariables();
dvar.dummy = “dummy”;
newsrequest.data = dvar;
newsrequest.method = URLRequestMethod.POST;
newsloader.load(newsrequest);
newsloader.addEventListener(Event.COMPLETE, loaded);
titlenews.autoSize = TextFieldAutoSize.LEFT;
bodynews.autoSize = TextFieldAutoSize.LEFT;
function loaded(event:Event){
newsxml = new XML(event.target.data);
newsxml.ignoreWhitespace = true;
trace(newsxml);
}
HOWEVER, if i replace the
“ds.WriteXml(Response.OutputStream, XmlWriteMode.WriteSchema)”
with
"ds.WriteXml(“C:
ew.xml”)
it works. but the request for data varies (modifying sql statement in near future) and i don’t wish to create a new .xml for each of it.
Please tell me whats wrong with this…
or is there a better method?