Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 栏「;ColumnName";不属于这张桌子_C#_Asp.net_Sql Server 2008_Iis - Fatal编程技术网

C# 栏「;ColumnName";不属于这张桌子

C# 栏「;ColumnName";不属于这张桌子,c#,asp.net,sql-server-2008,iis,C#,Asp.net,Sql Server 2008,Iis,我知道有很多问题都与我的问题有关。但我的代码中有具体的问题 我已经在asp.net 3.5和SQL server 2008中开发了一个应用程序,并在具有Windows server 2003操作系统的计算机上托管在IIS 6.0中进行测试。对于7个用户来说,它运行良好,但对于7个以上的用户,它会给出错误“Column'ColumnName'不属于表”。这个错误经常出现在任何页面上。它也在本地计算机上运行,但在IIS上托管后出现错误。 以下是页面结构和代码文件,供您参考 <asp:Conte

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

我已经在asp.net 3.5和SQL server 2008中开发了一个应用程序,并在具有Windows server 2003操作系统的计算机上托管在IIS 6.0中进行测试。对于7个用户来说,它运行良好,但对于7个以上的用户,它会给出错误“Column'ColumnName'不属于表”。这个错误经常出现在任何页面上。它也在本地计算机上运行,但在IIS上托管后出现错误。 以下是页面结构和代码文件,供您参考

<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>
提前谢谢

我得到了解决方案。 在执行存储过程时,我手动设置了命令.CommandTimeout=800,这对于服务器上的许多用户都不起作用。我刚刚评论了这句话,效果很好:)
谢谢。

您将在两个不同的位置绑定网格。错误发生在哪里?它是只在一个绑定调用中发生,还是在其中任何一个绑定调用中发生?你能追踪到数据库中的实际查询吗?另一个问题是我声明了静态连接。您可以编辑答案并更新它,而不是添加额外的注释:)
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();
    }