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.
|
|
|
|
|
![]() |
||
ASP ADO Connection to return XML from SQL Proc
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
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 |
|
|
|
|||
|
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 ) ? |
![]() |
| Tags |
| asp, ado, connection, return, xml, sql, proc |
| Thread Tools | |
|
|
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 |