I am using the following code as per Microsoft to convert a Dataset to XML for use in a Chartspace:
What I want to do is replace the code in red with a connection string and SQL command that is passed from the page designed to call the class. What am I missing that is likely to be obvious? Thanks...
Code:
Imports System.Web
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Data
Imports System.Data.SqlClient
Public Class MakeData
Implements IHttpHandler
Public ReadOnly Property IsReusable() As Boolean _
Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
Public Sub ProcessRequest(ByVal context As HttpContext) _
Implements IHttpHandler.ProcessRequest
Dim sConn As String = [red]"User ID=<username>;Password=<password>;Initial Catalog=Northwind;Data Source=YourSQLServer;"[/red]
Dim sSQL As String = _
[red]"SELECT LastName, Sum([UnitPrice]*[Quantity]*(1-[Discount])) AS OrderTotal " & _
"FROM Employees INNER JOIN (Orders INNER JOIN [Order Details] ON " & _
"Orders.OrderID = [Order Details].OrderID) ON Employees.EmployeeID = " & _
"Orders.EmployeeID GROUP BY LastName"[/red]
'Connect to the data source.
Dim nwindConn As SqlConnection = New SqlConnection(sConn)
nwindConn.Open()
'Build a dataSet for Employee Sales.
Dim ds As DataSet
ds = New DataSet("MyDataset")
Dim da As SqlDataAdapter = New SqlDataAdapter(sSQL, nwindConn)
da.Fill(ds)
'Transform the dataSet using the stylesheet.
Dim xmlDoc_ds As XmlDataDocument = New XmlDataDocument(ds)
Dim xslTran As XslTransform = New XslTransform()
xslTran.Load(context.Server.MapPath("Rowset.xslt"))
'Return the persisted recordset.
context.Response.ContentType = "text/xml"
context.Response.Charset = ""
xslTran.Transform(xmlDoc_ds, Nothing, context.Response.Output)
End Sub
End Class
What I want to do is replace the code in red with a connection string and SQL command that is passed from the page designed to call the class. What am I missing that is likely to be obvious? Thanks...