SQLXML code sample in ASP

DETAILS

<%

Response.ContentType = "text/xml"
Dim oCmd, sSQL 

sSQL = "<root><sql:query xmlns:sql='urn:schemas-microsoft-com:xml-sql'>" & _
       "Select Lastname, Firstname, City from Employees order by Firstname FOR XML AUTO </sql:query></root>" 

Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection = ("Provider=sqlxmloledb.3.0;data provider=sqloledb;Data Source=SQL Server;user id=SQL user;password=password;Initial Catalog=database") 

oCmd.CommandText = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}" 

oCmd.Properties("Output Stream") = Response
oCmd.Execute , , 1024 

Set oCmd = Nothing

%>

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Query MS SQL Database with PHP

DETAILSBelow is a simple PHP script to demonstrate how to connect to a MS SQL database using an...

Query MySQL database in ASP

DETAILS<%Dim cnnSimple  ' ADO connectionDim rstSimple  ' ADO recordsetSet cnnSimple...

Query MySQL Database in PHP

DETAILS<html><head><title>MySQL Test...

Redirect a subdomain to a subdirectory

DETAILS You can redirect a subdomain to a subdirectory by using ASP or ASP.net...

Insert data into a MS SQL database with .NET SQL Data Provider in ASP.NET

 DETAILS  <%@ import namespace="system.data.sqlclient" %><Script...