iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Reply
 
LinkBack Thread Tools
Old August 11th, 2005, 06:28 AM   #1
New Member
 

Join Date: Aug 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 NickyJ is on a distinguished road
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
NickyJ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old August 11th, 2005, 07:21 AM   #2
WebForumz Member
 

Join Date: Feb 2004
Location: Woodbridge, UK
Age: 28
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Trebz is on a distinguished road
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
)

?
Trebz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old August 11th, 2005, 08:39 AM   #3
New Member
 

Join Date: Aug 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 NickyJ is on a distinguished road
No joy there
NickyJ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

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


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 February 14th, 2007 11:39 AM
'Return to top' trouble? Kymberly PHP 3 August 3rd, 2006 12:49 PM
Dynamic Stored Proc kebi Databases 0 November 2nd, 2005 02:25 AM
Stored proc kebi Databases 0 October 28th, 2005 08:17 AM
return from db benbramz Classic ASP 5 June 19th, 2005 03:29 PM


Search Engine Optimization by vBSEO 3.2.0 RC8