streaming xml???

D

dfetrow410

I am using a xsl template, but I need to create that on the fly into a
stream. As well ast the xml file generated by the database. Can anyone
help me. My working code is below....


String conn = "Password=sa;User ID=sa;Initial Catalog=pubs;Data
Source=xxxxxx";
String sql = "Select * From Royalties ";
String xslPath = "RoyaltyReportStyle.xsl";
String ServerPath = HttpContext.Current.Server.MapPath("\\" +
ConfigurationSettings.AppSettings["xmlPath"] + "\\");

//Filter for a selected author
//DataRowView item = (DataRowView)nameList.Items[index];
String filter = "Karsen";

//Get Royalty data
SqlDataAdapter adapter = new SqlDataAdapter();
SqlConnection connection = new SqlConnection(conn);
SqlCommand command = new SqlCommand(sql + "where au_lname='" +
filter + "'", connection);
adapter.SelectCommand = command;
DataSet data = new DataSet("root");
adapter.Fill(data, "royalties");

//Transform the data
// string val = HttpContext.Current.Server.MapPath("\\" +
ConfigurationSettings.AppSettings["xmlPath"] + "\\" + filter + ".xml");
data.WriteXml(ServerPath + filter + ".xml");
// data.WriteXml("C:\\Inetpub\\wwwroot\\excelTransform\\Karsen.xml");

// Create a resolver with default credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials =
System.Net.CredentialCache.DefaultCredentials;

// Create the XslTransform object.
XslTransform xslt = new XslTransform();

// Load the stylesheet.
xslt.Load("http://localhost/excelTransform/RoyaltyReportStyle.xsl",
resolver);

// Transform the file.
xslt.Transform(ServerPath + filter + ".xml", ServerPath + filter +
"Report.xml", resolver);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top