G
Guest
I have a sproc that returns xml data in an output parameters and I get an
error.
It works fine within the SQL05 environment but barfs in VS05.
Are their any fixes or work arounds?
SqlCommand cmd = new SqlCommand("web.SurveyAndTransform", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p0 = new SqlParameter("@SurveyID", SqlDbType.Int);
p0.Direction = ParameterDirection.Input;
p0.Value = surveyID;
cmd.Parameters.Add(p0);
SqlParameter p1 = new SqlParameter("@xmlData", SqlDbType.Xml);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
SqlParameter p2 = new SqlParameter("@xslt", SqlDbType.Xml);
p2.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p2);
conn.Open();
cmd.ExecuteNonQuery();
ERROR String[1]: the Size property has an invalid size of 0.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [web].[SurveyResultAndTransform]
(
@SurveyID int,
@xmlData xml OUT,
@xlst xml OUT
)
AS
SET NOCOUNT ON
set @xlst = (
SELECT SurveyTransforms.Transform
FROM SurveyProfiles
INNER JOIN Surveys ON SurveyProfiles.SurveyProfileID =
Surveys.SurveyProfileID
INNER JOIN SurveyTransforms ON SurveyProfiles.SurveyTransformIdReport =
SurveyTransforms.SurveyTransformID
where SurveyID=@SurveyID) ;
--Now create the XML results
with
question ( QuestionID ) as
(Select distinct QuestionID From SurveyResults Where
SurveyID=@SurveyID),
results ( QuestionID, Answer, AnswerCount) as
(Select QuestionID, Answer, Count(Answer)
From SurveyResults
Where SurveyID=@SurveyID
group by questionid, answer)
select SurveyName, SurveyQuestions,
(
Select question.QuestionID, results.Answer, results.AnswerCount
From question join results
on question.questionid =results.questionid
for xml auto, type
)QuestionResults into #TempResultTable
from SurveyProfiles Join
Surveys on SurveyProfiles.SurveyProfileID = Surveys.SurveyProfileID
WHERE SurveyID=@SurveyID ;
set @xlst = (
select * from #TempResultTable
for xml Raw('Results'), Elements)
drop table #TempResultTable
error.
It works fine within the SQL05 environment but barfs in VS05.
Are their any fixes or work arounds?
SqlCommand cmd = new SqlCommand("web.SurveyAndTransform", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p0 = new SqlParameter("@SurveyID", SqlDbType.Int);
p0.Direction = ParameterDirection.Input;
p0.Value = surveyID;
cmd.Parameters.Add(p0);
SqlParameter p1 = new SqlParameter("@xmlData", SqlDbType.Xml);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
SqlParameter p2 = new SqlParameter("@xslt", SqlDbType.Xml);
p2.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p2);
conn.Open();
cmd.ExecuteNonQuery();
ERROR String[1]: the Size property has an invalid size of 0.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [web].[SurveyResultAndTransform]
(
@SurveyID int,
@xmlData xml OUT,
@xlst xml OUT
)
AS
SET NOCOUNT ON
set @xlst = (
SELECT SurveyTransforms.Transform
FROM SurveyProfiles
INNER JOIN Surveys ON SurveyProfiles.SurveyProfileID =
Surveys.SurveyProfileID
INNER JOIN SurveyTransforms ON SurveyProfiles.SurveyTransformIdReport =
SurveyTransforms.SurveyTransformID
where SurveyID=@SurveyID) ;
--Now create the XML results
with
question ( QuestionID ) as
(Select distinct QuestionID From SurveyResults Where
SurveyID=@SurveyID),
results ( QuestionID, Answer, AnswerCount) as
(Select QuestionID, Answer, Count(Answer)
From SurveyResults
Where SurveyID=@SurveyID
group by questionid, answer)
select SurveyName, SurveyQuestions,
(
Select question.QuestionID, results.Answer, results.AnswerCount
From question join results
on question.questionid =results.questionid
for xml auto, type
)QuestionResults into #TempResultTable
from SurveyProfiles Join
Surveys on SurveyProfiles.SurveyProfileID = Surveys.SurveyProfileID
WHERE SurveyID=@SurveyID ;
set @xlst = (
select * from #TempResultTable
for xml Raw('Results'), Elements)
drop table #TempResultTable