Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 3rd, 2003, 04:30 PM
Authorized User
 
Join Date: Nov 2003
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default FOR XML Explicit and ASP

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
%>


Reply With Quote
  #2 (permalink)  
Old April 8th, 2005, 10:41 AM
JDS JDS is offline
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to JDS Send a message via AIM to JDS Send a message via MSN to JDS
Default

What was the answer to this problem? I'm having the same issue now.

Reply With Quote
Reply


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 bmains SQL Server 2000 5 March 8th, 2004 09:18 AM
SQL Server For XML Explicit tonyellard Classic ASP Databases 0 November 3rd, 2003 03:03 PM
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 06:58 AM.


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