这很奇怪。在新闻详细信息页面中,我想通过一个查询从不同的表中获取一些不同的值。但是,由于一些奇怪的原因,我只能得到两个值。结果如下:
<Desc></Desc>
<Date/>
</row>
</rows>
如果我禁用全名,那么我会获得shortdesc而不是其他人。其他人也一样。
NewsID = Request.QueryString("NEWSID")
SQL = "SELECT N.NewsID, N.MembersID, N.CategoriesID, N.ImagesID, N.NewsTitle, N.NewsShortDesc, N.NewsDesc, N.NewsActive, N.NewsDateEntered, C.CategoriesID, C.CategoriesName, M.MembersID, M.MembersFullName"
Set objViewNews = objConn.Execute(SQL)
With Response
.Write "<?xml version='1.0' encoding='windows-1254' ?>"
.Write "<rows>"
End With
With Response
.Write "<row id='"& objViewNews("NewsID") &"'>"
.Write "<FullName>"& objViewNews("MembersFullName") &"</FullName>"
.Write "<CategoryName>"& objViewNews("CategoriesName") &"</CategoryName>"
.Write "</row>"
End With
With Response
.Write "</rows>"
End With
objViewNews.Close
Set objViewNews = Nothing
答案 0 :(得分:0)
SQL = SQL & " Where N.NewsId = " & SqlString("int", newsId)
4.您可以考虑使用JOIN语法:
(假定输入检查功能)
SQL = "SELECT N.NewsID, N.MembersID, N.CategoriesID, N.ImagesID, N.NewsTitle, N.NewsShortDesc, N.NewsDesc, N.NewsActive, N.NewsDateEntered, C.CategoriesID, C.CategoriesName, M.MembersID, M.MembersFullName"
SQL = SQL & " FROM News N"
SQL = SQL & " Inner Join Categories C"
SQL = SQL & " On C.CategoriesID = N.CategoriesID"
SQL = SQL & " Inner Join Members M"
SQL = SQL & " On M.MembersID = N.MembersID"
SQL = SQL & " Where N.NewsId = " & SqlString(VariantType.Integer
, NewsId)
SQL = SQL & " And N.NewsActive = 1"
(男人的格式可能很古怪)
编辑您应该尝试将所有值包装在CDATA中,如下所示:
With Response
.Write "<row id='"& objViewNews("NewsID") &"'>"
.Write "<FullName><![CDATA["& objViewNews("MembersFullName") &"]]></FullName>"
.Write "<CategoryName><![CDATA["& objViewNews("CategoriesName") &"]]></CategoryName>"
.Write "<Title><![CDATA["& objViewNews("NewsTitle") &"]]></Title>"
.Write "<ShortDesc><![CDATA["& objViewNews("NewsShortDesc") &"]]></ShortDesc>"
.Write "<Desc><![CDATA["& objViewNews("NewsDesc") &"]]></Desc>"
.Write "<Date>"& objViewNews("NewsDateEntered") &"</Date>"
.Write "</row>"
End With
我没有将日期值包装在CDATA中,尽管您也可以考虑这样做以确定。