我有一個存儲過程,我正在使用交叉應用從表中獲取一個字段「tagtext」,然後將每個tagtext作爲一個條目放在名爲另一個表中的標記的新字段中。我不想熱衷於如何交叉應用作品,但似乎得到一個錯誤:無效的對象myArticles。存儲過程中的obj名稱無效
從我的SP相關的代碼是:
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @RowStart int
declare @RowEnd int
IF (@Page=1)
Begin
set @RowStart=(@Page-1)*(@PageLen)
set @RowEnd=(@[email protected]);
END
ELSE
BEGIN
set @RowStart=((@Page-1)*(@PageLen))+1
set @RowEnd=((@[email protected]))-1
END;
With myArticles as
(select ROW_NUMBER() over (ORDER BY publicationdate DESC) as 'RowNumber',*
From article_v
where articleID in(select articleID from savedarticle where userID= @UserID) and
title like '%'[email protected]+'%' and
title like '%'[email protected]+'%' and
title like '%'[email protected]+'%' and
title like '%'[email protected]+'%' and
title like '%'[email protected]+'%'
)
(select mA.*,
isnull(left(Tags,len(Tags)-1),'') as Tags
from myArticles mA
cross apply (select tagtext +', '
from usertag uTag
where [email protected] and uTag.usertagID in(select usertagID from articletag aTag where aTag.articleID=mA.articleID)
for xml path('')) ca(Tags)
)
select
rownumber,journalID,journalname,articleID,title,publicationdate,medabbr, authors, Tags
from myArticles where RowNumber Between @RowStart and @RowEnd
END
GO
然後,我使用的SP在Web服務:
<WebMethod()> _
Public Function GetSavedArticlesWithAbbr(ByVal mobileGUID As String, ByVal pageNum As Integer, ByVal pageLen As Integer, ByVal keywords As String) As List(Of ipadArticle)
Dim result As New List(Of ipadArticle)
keywords = HttpUtility.UrlDecode(keywords)
Dim tempParamKW() As String = {"", "", "", "", ""}
Dim tempKW() As String = keywords.Split(" ")
Dim tempILoop As Integer = 0
For Each s As String In tempKW
tempParamKW(tempILoop) = s.Trim
tempILoop += 1
Next
Dim simpuser As SimpleUser = utils.GetSimpleUserInfoFromMobileGUID(mobileGUID)
If simpuser.isValid Then
Dim lq As New lqDFDataContext
Dim var = lq.mobile_GetSavedArticlesJW(simpuser.UserID, tempParamKW(0), tempParamKW(1), tempParamKW(2), tempParamKW(3), tempParamKW(4), pageNum, pageLen)
For Each a_var In var
Dim ipadartcicle As New ipadArticle()
ipadartcicle.ArticleID = a_var.articleID
ipadartcicle.PublishedOn = a_var.publicationdate
ipadartcicle.Title = a_var.title
ipadartcicle.MedAbbr = a_var.medabbr.Replace(" ", "-").ToLower()
Dim tempTags() As String = a_var.Tags.Split(",")
For Each t As String In tempTags
ipadartcicle.Tags.Add(t)
Next
Dim tempAuthors() As String = a_var.Authors.Split(",")
For Each a As String In tempAuthors
ipadartcicle.Authors.Add(a)
Next
result.Add(ipadartcicle)
Next 'this is where i get the error
End If
Return result
End Function
沒有你的SP運行?我懷疑它 – codingbiz 2012-08-09 00:27:46