首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >列"ColumnName“不属于该表

列"ColumnName“不属于该表
EN

Stack Overflow用户
提问于 2011-02-04 20:25:29
回答 1查看 3.5K关注 0票数 0

我知道有很多问题都与我的问题有关。但我的代码中有特定的问题。

我已经用SQL3.5和SQLserver2008开发了一个应用程序,并在装有asp.net Server2003操作系统的机器上托管在IIS6.0中进行测试。它对于7个用户运行得很好,但是对于超过7个用户,它会给出错误“列'ColumnName‘不属于表”。而且这个错误经常出现在任何页面上。它也在本地计算机上运行,但在IIS上托管后会出现错误。下面是页面结构和代码文件,供您参考。

代码语言:javascript
复制
<asp:Content ID="Content2" ContentPlaceHolderID="AdminMasterContentPlaceHolder" runat="Server">
<div>
    <asp:UpdatePanel ID="upGroups" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="pnlGroups" runat="server" Width="90%">
                <table>
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblGroups" runat="server" Text="Groups" class="altheading"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td><asp:Label ID="lblshow" runat="server" Text="" ForeColor="Red" CssClass="altlabel"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Button ID="imgAddGroup" runat="server" Text="Add Group" OnClick="imgAddGroup_Click" />
                            <asp:Button ID="imgdeleteGroup" runat="server" Text="Delete" OnClick="imgdeleteGroup_Click"
                                CausesValidation="False" OnClientClick="javascript:return confirm('Do you want to delete the record?');" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:GridView ID="grdviewGroups" runat="server" AutoGenerateColumns="False" DataKeyNames="GroupID"
                                AllowPaging="True" AllowSorting="True" OnDataBound="grdviewGroups_DataBound"
                                OnRowCommand="grdviewGroups_RowCommand" Width="500px" OnPageIndexChanging="grdviewGroups_PageIndexChanging"
                                OnSelectedIndexChanged="grdviewGroups_SelectedIndexChanged1" CssClass="gridtable">
                                <EmptyDataTemplate>
                                    <asp:Label ID="lblemptygridmsg" runat="server" Text="There is no data to show"></asp:Label></EmptyDataTemplate>
                                <Columns>
                                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                                        <EditItemTemplate>
                                            <asp:CheckBox ID="chkGroups" runat="server" />
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkGroups" runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="RowNumber" HeaderText="Id" ItemStyle-HorizontalAlign="Center" />
                                    <asp:BoundField DataField="GroupID" Visible="False" />
                                    <asp:TemplateField HeaderText="Group Code">
                                        <ItemStyle HorizontalAlign="Left" ForeColor="#0033CC" />
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkGroupCode" runat="server" CommandName="GroupCode" Text='<%# Eval("GroupCode") %>'
                                                CommandArgument='<%# Eval("GroupID") %>' Font-Underline="True" ForeColor="#0033CC"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Group Name">
                                        <ItemStyle HorizontalAlign="left" ForeColor="#0033CC" />
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkGroupName" runat="server" CommandName="GroupName" Text='<%# Eval("GroupName") %>'
                                                CommandArgument='<%# Eval("GroupID") %>' Font-Underline="True" ForeColor="#0033CC"></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="GroupDescription" HeaderText="Description" />
                                </Columns>
                            </asp:GridView>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

代码语言:javascript
复制
public partial class Admin_Groups : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
     ValidateUserLogin.UserLoginRequired();
        if (!IsPostBack)
        {
            //on page load, show GroupGrid
            BindGGrid();
        }

    }
    protected void grdviewGroups_DataBound(object sender, EventArgs e)
    {

    }
    //show GroupGrid
    public void BindGGrid()
    {
        Groups gps = new Groups();
        grdviewGroups.DataSource = gps.ShowAllGroups();
        grdviewGroups.DataBind();
    }

    protected void grdviewGroups_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        Groups gps = new Groups();
        //int id = Convert.ToInt32(grdviewGroups.DataKeys[row.RowIndex].Value);
        if (e.CommandName == "GroupCode")
        {
            Response.Redirect("AddEditGroups.aspx?ID=" + gps.Encryptid((e.CommandArgument.ToString())));
        }

        else if (e.CommandName == "GroupName")
        {
            Response.Redirect("AddEditGroups.aspx?ID=" + gps.Encryptid((e.CommandArgument.ToString())));
        }
    }
    protected void grdviewGroups_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
  protected void imgdeleteGroup_Click(object sender, EventArgs e)
    {
        // to delete group data by groupid
        string gpsid = string.Empty;
        int id;
        Groups gps = new Groups();

        foreach (GridViewRow row in grdviewGroups.Rows)
        {
            CheckBox checkbox = (CheckBox)row.FindControl("chkGroups");
            if (checkbox.Checked)
            {
                id = Convert.ToInt32(grdviewGroups.DataKeys[row.RowIndex].Value);
                gpsid = gpsid + id + ",";
            }
        }
        //string str1 = gpsid;
        //gps.DeleteGroup(str1);
        //grdviewGroups.DataSource = gps.ShowAllGroups();
        //grdviewGroups.DataBind();
        string str1 = gpsid;
        int a=gps.DeleteGroup(str1);
        if (a == 1)
        {
            lblshow.Text = "You can not delete this record because there is reference in database"; 
        }
        else
        {
            if (gpsid == "")
            {
                lblshow.Text = "Please select the record that you want to delete!";
            }
            else
            {
                lblshow.Text = "Record is deleted";
            }


        }
        grdviewGroups.DataSource = gps.ShowAllGroups();
        grdviewGroups.DataBind();
    }
    protected void imgAddGroup_Click(object sender, EventArgs e)
    {
        Response.Redirect("AddEditGroups.aspx");
    }
    protected void grdviewGroups_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdviewGroups.PageIndex = e.NewPageIndex;
        BindGGrid();
    }

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-02-05 13:52:20

我找到解决方案了。我在执行存储过程时手动设置了command.CommandTimeout=800,这对服务器上的许多用户都不起作用。我只注释了这一行,效果很好:)谢谢。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4897927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档