ASP ADO Connection to return XML from SQL Proc

This is a discussion on "ASP ADO Connection to return XML from SQL Proc" within the Classic ASP section. This forum, and the thread "ASP ADO Connection to return XML from SQL Proc are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 11th, 2005, 09:28
New Member
Join Date: Aug 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ASP ADO Connection to return XML from SQL Proc

Hi there,

I have the following SQL Stored Procedure

CREATE PROCEDURE pr_GetJobInfo2
@JobType int,
@CntryID int,
@JobTitle varchar(8000) OUTPUT
AS
SELECT @JobTitle = ltrim(rtrim(JobTitle))
FROM dbo.JOBS
WHERE JobType = @JobType
AND CntryID = @CntryID
FOR XML AUTO
GO


I wish to call this Procedure through an ASP page and return the XML

Currently I'm getting the following error

Microsoft OLE DB Provider for SQL Server error '80040e14'

The FOR XML clause is not allowed in a ASSIGNMENT statement.

/xml_folder/Nick6.asp, line 34


Code at the moment is :

<% dim cn
dim cmd
dim p
dim pJobID
dim pJobTitle
dim retvalue
dim rs

cn = "Provider=SQLOLEDB.1;Data Source=lon-nt-sq02; Initial Catalog=hncom; user id = 'sa';password='passw0rd'"

Set cmd = Server.CreateObject ("ADODB.Command")

cmd.ActiveConnection = cn
cmd.CommandText = "pr_GetJobInfo2"
cmd.CommandType = adCmdStoredProc

set p = cmd.Parameters
p.Append cmd.CreateParameter("JobType", adInteger, adParamInput)
p.Append cmd.CreateParameter("CntryID", adInteger, adParamInput)
p.Append cmd.CreateParameter("JobTitle", adVarChar, adParamOutput,500)

cmd("JobType")= 1
cmd("CntryID")= 6

Set rs = cmd.Execute

Response.write rs.Fields.Item("XML_F52E2B61-18A1-11d1-B105-00805F49916B").Value

' clean up
If rs.State = adStateOpen then
rs.Close
End If
If cmd.State = adStateOpen then
cmd.Close
End If

Set rs = Nothing
Set cmd = Nothing

%>


Thanks all
Reply With Quote

  #2 (permalink)  
Old Aug 11th, 2005, 10:21
Up'n'Coming Member
Join Date: Feb 2004
Location: Woodbridge, UK
Age: 27
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Hi

I reckon that error just means what it says, in that you cannot assign the results from FOR XML to a @variable.

Can you try doing:

CREATE PROCEDURE pr_GetJobInfo2
@JobType int,
@CntryID int,
@JobTitle varchar(8000) OUTPUT
AS
SELECT @JobTitle = (
SELECT [field] = ltrim(rtrim(JobTitle))
FROM dbo.JOBS
WHERE JobType = @JobType
AND CntryID = @CntryID
FOR XML AUTO
)

?
Reply With Quote
  #3 (permalink)  
Old Aug 11th, 2005, 11:39
New Member
Join Date: Aug 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
No joy there
Reply With Quote
Reply

Tags
asp, ado, connection, return, xml, sql, proc

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
stored proc neoandzuco Databases 1 Feb 14th, 2007 14:39
'Return to top' trouble? Kymberly PHP Forum 3 Aug 3rd, 2006 15:49
Dynamic Stored Proc kebi Databases 0 Nov 2nd, 2005 05:25
Stored proc kebi Databases 0 Oct 28th, 2005 11:17
return from db benbramz Classic ASP 5 Jun 19th, 2005 18:29


All times are GMT. The time now is 10:10.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43