孟老师 , 您好 , 有个问题要向您请教 ? 我在用asp.net + sql server 2000做完网站后在本机上测试一切都正常 , 但是程序更新到正式后经常会出现 列“xxx”不属于表 Table 或者 xxx既不是表 Table 的 DataColumn 也不是 DataRelation。 这样的问题 , 但是程序在调用存储过程的时候返回的dataset中都有这些字段 , 而且这样的问题是隔一段时间就发生麻烦您帮我看看吧。。谢谢了
下面是我其中的一个存储过程 , 当程序调用这个存储过程后在页面中使用返回的dataset的时候就会提示 列“xxx”不属于表 Table这样的错误 :
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[SP_GetRecommendRedemptionList]
-- Add the parameters for the stored procedure here
@LanguageCode VARCHAR(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @SQL VARCHAR(1000); -- Insert statements for procedure here Begin Try SET @SQL = 'SELECT c.SortCode, b.[Name] as RedemptionName, b.[Title], b. [Description],
a.ID as RedemptionId, Convert(decimal(10,0), a.points) as points,
Replace(replace(a.ImageUrl, ''\'',''/''), ''~'', ''..'') as RedemptionImageUrl,
a.Quantity , CONVERT(varchar(12), a.ExpireDate, 111) as ExpireDate
FROM Redemption a
Inner Join RedemptionCategory c On a.categoryId=c.categoryId
INNER JOIN RedemptionLang b
ON a.ID=b.RedemptionID
AND a.ExpireDate>getdate() AND a.IsRecommend=1
AND b.LanguageCode = ''' + @LanguageCode + ''' Order by c.SortCode, a.SortCode, b.[name]';
EXEC(@SQL)
End Try Begin Catch
DECLARE @ErrorMessage VARCHAR(255)
DECLARE @ErrorSeverity INT
DECLARE @ErrorState INT
SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE() RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState)
End Catch
END
下面是我其中的一个存储过程 , 当程序调用这个存储过程后在页面中使用返回的dataset的时候就会提示 列“xxx”不属于表 Table这样的错误 :
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[SP_GetRecommendRedemptionList]
-- Add the parameters for the stored procedure here
@LanguageCode VARCHAR(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @SQL VARCHAR(1000); -- Insert statements for procedure here Begin Try SET @SQL = 'SELECT c.SortCode, b.[Name] as RedemptionName, b.[Title], b. [Description],
a.ID as RedemptionId, Convert(decimal(10,0), a.points) as points,
Replace(replace(a.ImageUrl, ''\'',''/''), ''~'', ''..'') as RedemptionImageUrl,
a.Quantity , CONVERT(varchar(12), a.ExpireDate, 111) as ExpireDate
FROM Redemption a
Inner Join RedemptionCategory c On a.categoryId=c.categoryId
INNER JOIN RedemptionLang b
ON a.ID=b.RedemptionID
AND a.ExpireDate>getdate() AND a.IsRecommend=1
AND b.LanguageCode = ''' + @LanguageCode + ''' Order by c.SortCode, a.SortCode, b.[name]';
EXEC(@SQL)
End Try Begin Catch
DECLARE @ErrorMessage VARCHAR(255)
DECLARE @ErrorSeverity INT
DECLARE @ErrorState INT
SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE() RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState)
End Catch
END
给成 print @Sql
输出看看。
<asp:DataList ID="RecommendRedemptionList1" BorderColor="red" runat="server" RepeatColumns="4">
<ItemStyle VerticalAlign="Top" Width="130" />
<ItemTemplate>
<table border="0" style="margin-left:3px; margin-top:1px; vertical-align:top;">
<tr>
<td><asp:ImageButton runat="server" Width="129" Height="80" BorderColor="blue" ID="RecommendImage1" ImageUrl='<%#((DataRowView)Container.DataItem)["RedemptionImageUrl"]%>' OnClick="RecommendImage1_Click" CommandArgument='<%#((DataRowView)Container.DataItem)["RedemptionId"]%>'></asp:ImageButton></td>
</tr>
<tr>
<td><asp:Label runat="server" ID="RedemptionName1" Text='<%#((DataRowView)Container.DataItem)["RedemptionName"]%>'></asp:Label></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="RedemptionDoints1" Text='<%# string.Format("{0:N0}", Convert.ToInt32(((DataRowView)Container.DataItem)["points"])) %>'></asp:Label>
<asp:Label ID="AB88Point" runat="server" meta:resourceKey="AB88PointResource"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
后台绑定代码如下 :
protected void InitializeRecommend()
{
string language = GetLanguage(); try
{
DataSet ds = BO_Redemption.Instance.GetRecommendRedemptionList(language);
if (ds != null && ds.Tables.Count > 0)
{
DataTable dt = ds.Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
this.RecommendRedemptionList1.DataSource = dt;
this.RecommendRedemptionList1.DataBind();
}
}
}
catch (Exception ex)
{
string url = this.Page.Request.Url.LocalPath;
LogUtility.LogWrite(url, "InitializeRecommend", ex);
}
}数据库存储过程如下 :
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
goALTER PROCEDURE [dbo].[SP_GetRecommendRedemptionList]
-- Add the parameters for the stored procedure here
@LanguageCode VARCHAR(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @SQL VARCHAR(1000); -- Insert statements for procedure here Begin Try SET @SQL = 'SELECT c.SortCode, b.[Name] as RedemptionName, b.[Title], b. [Description],
a.ID as RedemptionId, Convert(decimal(10,0), a.points) as points,
Replace(replace(a.ImageUrl, ''\'',''/''), ''~'', ''..'') as RedemptionImageUrl,
a.Quantity , CONVERT(varchar(12), a.ExpireDate, 111) as ExpireDate
FROM Redemption a
Inner Join RedemptionCategory c On a.categoryId=c.categoryId
INNER JOIN RedemptionLang b
ON a.ID=b.RedemptionID
AND a.ExpireDate>getdate() AND a.IsRecommend=1
AND b.LanguageCode = ''' + @LanguageCode + ''' Order by c.SortCode, a.SortCode, b.[name]';
EXEC(@SQL)
End Try Begin Catch
DECLARE @ErrorMessage VARCHAR(255)
DECLARE @ErrorSeverity INT
DECLARE @ErrorState INT
SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE() RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState)
End Catch
END
我在VS2005上调试都运行很正常 , 但更新正式机后隔一段时间就报这样的错误出来。请指教 ?
a.ID as RedemptionId, Convert(decimal(10,0), a.points) as points,
Replace(replace(a.ImageUrl, '\','/'), '~', '..') as RedemptionImageUrl,
a.Quantity , CONVERT(varchar(12), a.ExpireDate, 111) as ExpireDate
FROM Redemption a
Inner Join RedemptionCategory c On a.categoryId=c.categoryId
INNER JOIN RedemptionLang b
ON a.ID=b.RedemptionID
AND a.ExpireDate>getdate() AND a.IsRecommend=1
AND b.LanguageCode = 'zh-cn' Order by c.SortCode, a.SortCode, b.[name]
头痛的是这个问题是偶尔才会报出来的 , 而且每次报这个问题出来都会连带出一系列的错误 , 请教各位专家还有没有其他的可能会出这个错 ?