【发布时间】:2011-11-18 11:06:15
【问题描述】:
错误信息是:
引发了“System.Web.HttpUnhandledException”类型的异常。 友好消息:System.ArgumentException:列'testfile'确实 不属于表。在 System.Data.DataRow.GetDataColumn(字符串 columnName) 在 System.Data.DataRow.get_Item(String columnName) 在 Registration_test.FillImage() 中 c:\inetpub\wwwroot\testWeb\Events\Registration.aspx.cs:第 49 行 Registration_test.Page_PreInit(Object sender, EventArgs e) in c:\inetpub\wwwroot\testWeb\test\Registration.aspx.cs:第 39 行 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,对象 o,对象 t,EventArgs e) 在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送者, EventArgs e) 在 System.Web.UI.Page.OnPreInit(EventArgs e) 在 System.Web.UI.Page.PerformPreInit() 在 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint) 目标站点:Boolean HandleError(System.Exception) 源:System.Web 错误堆栈跟踪是:在 System.Web.UI.Page.HandleError(Exception e) 在 System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest(布尔 includeStagesBeforeAsyncPoint,布尔型 includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest() 在 System.Web.UI.Page.ProcessRequest(HttpContext 上下文)在 ASP.events_registration_aspx.ProcessRequest(HttpContext context) 在 c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET 文件\testWeb\761ce6e4\d915dd85\App_Web_posk8hm6.6.cs:第 0 行 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤, Boolean & completedSynchronously)
当站点托管在 IIS 中时,我收到了上述错误作为电子邮件,但是当我在本地甚至在线检查代码时我没有收到它。错误表示即使查询返回 testfile 列也不属于 datable列。
任何人都可以帮助解决可能的原因..
///////////////////这是我的代码////////////////// //////////////////////////
public partial class Registration_Registration : System.Web.UI.Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
FillImage();
}
protected void FillImage()
{
string Query = "select t.header_image_file as 'HeaderImage',t.image,c.testfile from registrars c left join trade t on c.tradeid = t.tradeid and c.mainitemid = t.mainitemid ";
DataTable result = GetDataTable(Query);
if (result != null && result .Rows.Count > 0)
{
if (result .Rows[0]["testfile"] != null)
{
this.Theme = result .Rows[0]["testfile"].ToString().Trim();
this.MasterPageFile = result .Rows[0]["testfile"].ToString().ToLower().Trim() + ".master";
}
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
}}
【问题讨论】:
-
你想在你的代码中做什么?Registration.aspx.cs:line 49 只需检查一下,请更新你的答案
-
我不赞成:您从系统中复制/粘贴一条错误消息,甚至没有阅读它:“列'testfile'不属于表”->您没有在您的生产数据库!并在标题中更加明确。
-
remi bourgarel 希望你喜欢我的新标题。
-
能不能给使用GetDataTable的内容?
-
您找到解决方案了吗?我也有类似的情况。直到昨天这些错误开始出现时,一切都运行良好。据我所知,没有做出任何改变。而且我知道这是非常随机的,因为许多用户能够访问该页面,而对于某些页面错误。我一开始以为只是在高负载期间,但即使在低负载时间我也能看到错误。如果您发现任何有用的信息,请告诉我。谢谢!