Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 3rd, 2003, 03:03 PM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Server For XML Explicit

I am trying to use SQL Server to create my XML for me for certain applications. I have written a query that works perfect in Query Analyzer. However, when I try to use ASP to call the stored procedure with this query, everything goes bust. I've tried to loop through the recordset and response.write out each row, I've created a stream object, streamed from my command object into it, and then tried loading it into an XML object (which gives me an invalid character error), and I've tried streaming the results directly to the response object. In every case, I receive either no results on the screen, or in some cases I receive a Greek Letter Beta. I'm not sure exactly what I'm doing wrong, but I've read a buncjh of the articles available and I get the same results every time.

Below are the query and the asp code I used, The query attempts to get table and column information from the database and place it into XML. So I should get results like:
<rootElement>
   <table name="tablename">
      <column name="col1"/>
      <column name="col2"/>
      <column name="col3"/>
   </table>
   .
   .
   .
</rootElement>

Please HELP!!!

***********************************************
***********************************************
***********************************************

SELECT 1 as Tag,
              NULL as Parent,
              'RootElement' as [rootElement!1!elementname],
              NULL as [table!2!tName],
              NULL as [table!2!sysid],
              NULL as [column!3!cName],
              NULL as [column!3!type],
              NULL as [column!3!length],
              NULL as [column!3!isNullable],
              NULL as [column!3!isIdentity],
              NULL as [column!3!isPrimaryKey],
              NULL as [column!3!isForeignKey],
              NULL as [column!3!fkTable],
              NULL as [column!3!fkColumn]

UNION ALL

SELECT 2 as Tag,
              1 as Parent,
              'RootElement' as [rootElement!1!elementname],
              so.Name as [table!2!tName],
              so.id as [table!21!sysid],
              NULL as [column!3!cName],
              NULL as [column!3!type],
              NULL as [column!3!length],
              NULL as [column!3!isNullable],
              NULL as [column!3!isIdentity],
              NULL as [column!3!isPrimaryKey],
              NULL as [column!3!isForeignKey],
              NULL as [column!3!fkTable],
              NULL as [column!3!fkColumn]
FROM SysObjects so
WHERE so.xtype = 'U' AND
             NOT LEFT(so.Name, 2) Like 'dt'

UNION ALL

SELECT 3,
             2,
             'RootElement' as [rootElement!1!elementname],
             so.Name,
             so.id,
             sc.Name,
             (SELECT NAME FROM SysTypes WHERE xusertype = sc.xusertype),
             sc.length,
             sc.isNullable,
             (CASE columnproperty(sc.id, sc.Name, 'IsIdentity')
                  WHEN 1 THEN 'Yes' ELSE 'No'
              END),
             (CASE sc.typestat
                 WHEN 1 THEN 'Yes' ELSE 'No'
              END),
             (CASE
                 WHEN sf.fkey1 IS NULL THEN 'No' ELSE 'Yes'
              END),
             (SELECT Name FROM SysObjects WHERE id = sf.rkeyid),
             (SELECT Name FROM SysColumns WHERE id = sf.rkeyid AND colid=sf.rkey1)
FROM SysColumns sc
INNER JOIN SysObjects so ON sc.id = so.id
LEFT JOIN SysReferences sf ON so.id = sf.fkeyid AND
                                                 sc.colid = sf.fkey1
ORDER BY [table!2!tName], [column!3!cName]
FOR XML EXPLICIT



***********************************************
***********************************************
***********************************************
ASP CODE:


<%
On Error Resume Next
dim objStream
dim cn
dim com
dim objXML

set cn = Server.CreateObject("ADODB.Connection")
set com = Server.CreateObject("ADODB.Command")

cn.Open ODBCConnectString 'CONST variable from Globals2.asp
cn.CursorLocation = adUseClient

com.ActiveConnection = cn
com.CommandType = adCmdStoredProc
com.CommandText = "dbo.spGetTableXML" --Stored Procedure on Server.
com.Properties("Output Stream").Value = Response
com.Execute ,, adExecuteStream
%>



Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL XML Explicit (Output file required) Neal SQL Server 2005 0 August 4th, 2008 03:04 AM
XML EXPLICIT with text column stevemeyns SQL Server 2005 1 February 7th, 2007 01:09 PM
FOR XML Explicit and ASP tonyellard SQL Server ASP 1 April 8th, 2005 10:41 AM
For XML Explicit bmains SQL Server 2000 5 March 8th, 2004 09:18 AM
CDATA Set with For XML Explicit Yehuda SQL Server 2000 0 August 13th, 2003 01:50 PM



All times are GMT -4. The time now is 08:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.