fx.barrett
11-13-2008, 06:24 AM
Ok, I've been reading all kind of crap articles on this but couldn't find the thing I am looking for... It seems that everyone is using XmlDocument to create the XML structure and then pass it with a Write to Flash/Flex but that's not what I want...
I wrote a tiny web service which has a function in it, that reads some data from a DB and it should parse the read data to XML and then send it to my Flex app... the problem is the following: i have no idea what type of data should the function return and how can I parse my data with a DataSet and Adapter...
At the moment I have something like this ( which obsviously is not function ):
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Xml;
using System.Diagnostics;
namespace testApp
{
[WebService(Namespace = "http://wisebisoft.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class TestService : System.Web.Services.WebService
{
[WebMethod]
public string getPlayers()
{
string strConn = @"Server=.\sqlexpress; Database=Players; Trusted_Connection=yes; integrated security=yes";
SqlConnection conn = new SqlConnection(strConn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM Manufacturer";
da.SelectCommand = cmd;
da.Fill(ds, "Players");
return "no idea what to return";
}
}
}
Obviously the function's return type should be changed but I have no idea into what because C# data types are quite retarded and I couldn't figure out what on earth should the function return...
Anyway, I'd like to somehow create the XML structure from this function but without having to define manually all the stuff with XmlDocument, instead, I'd like to use the auto parsers...
Any help is really appreciated. ;)
I wrote a tiny web service which has a function in it, that reads some data from a DB and it should parse the read data to XML and then send it to my Flex app... the problem is the following: i have no idea what type of data should the function return and how can I parse my data with a DataSet and Adapter...
At the moment I have something like this ( which obsviously is not function ):
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Xml;
using System.Diagnostics;
namespace testApp
{
[WebService(Namespace = "http://wisebisoft.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class TestService : System.Web.Services.WebService
{
[WebMethod]
public string getPlayers()
{
string strConn = @"Server=.\sqlexpress; Database=Players; Trusted_Connection=yes; integrated security=yes";
SqlConnection conn = new SqlConnection(strConn);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM Manufacturer";
da.SelectCommand = cmd;
da.Fill(ds, "Players");
return "no idea what to return";
}
}
}
Obviously the function's return type should be changed but I have no idea into what because C# data types are quite retarded and I couldn't figure out what on earth should the function return...
Anyway, I'd like to somehow create the XML structure from this function but without having to define manually all the stuff with XmlDocument, instead, I'd like to use the auto parsers...
Any help is really appreciated. ;)