sql,asp.net,vb.net,sql-server-2005,datagrid , ASP DataGrid - Must declare the scalar variable “@LCompanyIDInt” [closed]


ASP DataGrid - Must declare the scalar variable “@LCompanyIDInt” [closed]

Question:

Tag: sql,asp.net,vb.net,sql-server-2005,datagrid

I have an application I'm working on that have multiple grid views on panels, and those panels are selected by a dropdown list. The first one I'll put here works perfectly.

I have a second grid set up exactly the same (I think) as the first. I've changed variable names a bit, and added a few extra rows for stuff, but otherwise things are identical.

On this second grid, I get an error that my first variable (LCompanyIDInt) is not declared. I have no clue why it says that.

I've pasted both the working & non-working code below. Removed a lot of columns for space reasons, but it always bombs on the LCompanyIDInt issue on the 2nd grid, for either inserting or updating. Resetting or cancelling works fine.

WORKING CODE:

    <!-- Total Points Annuity -->       
        <asp:Panel ID="TPAnnuity_Panel" runat="server" visible="true">  
                <asp:GridView ID="TPAnnuity_GridView" AllowSorting="true" AllowPaging="true" Runat="server"
                    DataSourceID="TPAnnuity_SqlDataSource" DataKeyNames="AnnuityTotalPointsID" 
                    AutoGenerateColumns="False" ShowFooter="true" PageSize="20">
                    <Columns>               
                        <asp:TemplateField HeaderText="ID" visible="False" InsertVisible="False" SortExpression="AnnuityTotalPointsID" HeaderStyle-VerticalAlign="Bottom">
                            <ItemTemplate>
                                <asp:Label ID="Label0" runat="server" Text='<%# Bind("AnnuityTotalPointsID") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:Label ID="EditAAnnuityTotalPointsID" runat="server" Text='<%# Bind("AnnuityTotalPointsID") %>'></asp:Label>
                            </EditItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Company" SortExpression="CompanyName" HeaderStyle-VerticalAlign="Bottom">
                            <ItemTemplate>
                                <asp:Label ID="Label11" runat="server" Text='<%# Bind("CompanyName") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditACompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName" selectedValue='<%# Bind("CompanyID") %>'></asp:DropDownList>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:DropDownList ID="NewCompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName"></asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="NewCompanyID" Display="Dynamic"  ForeColor="" ErrorMessage="You must enter a value. *" Enabled="false"></asp:RequiredFieldValidator>
                            </FooterTemplate>
                            <FooterStyle Wrap="False" />
                        </asp:TemplateField>    

                        <etc I ran out of room> 

                       <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ></asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="lbUpdate" runat="server" CausesValidation="False" CommandName="Update" Text="Update" ></asp:LinkButton>
                            <asp:LinkButton ID="lbCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:LinkButton ID="lbInsert" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" ></asp:LinkButton>
                            <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Reset"></asp:LinkButton>
                        </FooterTemplate>
                    </asp:TemplateField>

                    </Columns>
                </asp:GridView>

                <asp:SqlDataSource ID="TPAnnuity_SqlDataSource" Runat="server"
                    SelectCommand="SELECT * FROM tblTotalPointsAnnuity a left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
                    InsertCommand="INSERT INTO [tblTotalPointsAnnuity](CompanyID, ProductName, IssueAges, PlanTypeName, AgentFYC, AgentRenewal, ContractPoints, BonusPoints, IncludeInSummary, IncludeInTopPicks, ActiveProduct) VALUES(@CompanyIDInt, @ProductNameText, @IssueAgesText, @PlanTypeNameText, @AgentFYCInt, @AgentRenewalInt, @ContractPointsDec, @BonusPointsInt, @IncludeInSummaryInt, @IncludeInTopPicksInt, @ActiveProductInt) "
                    UpdateCommand="UPDATE [tblTotalPointsAnnuity] Set CompanyID = @CompanyIDInt, ProductName = @ProductNameText, IssueAges = @IssueAgesText, PlanTypeName = @PlanTypeNameText, AgentFYC = @AgentFYCInt, AgentRenewal = @AgentRenewalInt, ContractPoints = @ContractPointsDec, BonusPoints = @BonusPointsInt, IncludeInSummary = @IncludeInSummaryInt, IncludeInTopPicks = @IncludeInTopPicksInt, ActiveProduct = @ActiveProductInt WHERE [AnnuityTotalPointsID] = @AnnuityTotalPointsIDInt">
                    <InsertParameters>
                        <asp:Parameter Name="CompanyIDInt" Type="Int32" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="CompanyIDInt" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
        </asp:Panel>
<!-- END Total Points Annuity -->

WORKING CODE BEHIND

Sub TPAnnuity_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles TPAnnuity_GridView.RowCommand
    Dim TPAnnuity_searchStr As String = TPAnnuity_search_Text.Text

    If TPAnnuity_searchStr = "" Then
        TPAnnuity_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsAnnuity a " & _
                                        " left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
                                        " ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
    Else
        TPAnnuity_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsAnnuity a " & _
                                        " left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
                                    "WHERE 1=1 "

        If TPAnnuity_search_dropdown.SelectedValue = "Company" Then
            TPAnnuity_SqlDataSource.SelectCommand &= " AND ci.CompanyName like '%" & TPAnnuity_search_Text.Text & "%' OR ci.CompanyCode like '%" & TPAnnuity_search_Text.Text & "%'"
        Else If TPAnnuity_search_dropdown.SelectedValue = "CompanyID" Then
            TPAnnuity_SqlDataSource.SelectCommand &= " AND ci.CompanyID = " & TPAnnuity_search_Text.Text
        Else
            TPAnnuity_SqlDataSource.SelectCommand &= " AND " & TPAnnuity_search_dropdown.SelectedValue & " like '%" & TPAnnuity_search_Text.Text & "%' "
        End If
        TPAnnuity_SqlDataSource.SelectCommand &= " ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
    End If

    If e.CommandName = "Cancel" Then
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedIndex = 0
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text = ""
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewIssueAges"), TextBox).Text = ""
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text = ""
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewAgentFYC"), TextBox).Text = ""
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text = ""
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text = ""
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex = 0
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex = 0
        CType(TPAnnuity_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex = 0
    ElseIf e.CommandName = "Insert" Then
        TPAnnuity_SqlDataSource.InsertParameters.Clear()

        Dim test1 As New Parameter("CompanyIDInt", TypeCode.Int32)
        Dim test2 As New Parameter("ProductNameText", TypeCode.String)
        Dim test3 As New Parameter("IssueAgesText", TypeCode.String)
        Dim test4 As New Parameter("PlanTypeNameText", TypeCode.String)
        Dim test5 As New Parameter("AgentFYCInt", TypeCode.Int32)
        Dim test6 As New Parameter("AgentRenewalInt", TypeCode.String)
        Dim test7 As New Parameter("ContractPointsDec", TypeCode.Decimal)
        Dim test8 As New Parameter("BonusPointsInt", TypeCode.Decimal)
        Dim test9 As New Parameter("IncludeInSummaryInt", TypeCode.Byte)
        Dim test10 As New Parameter("IncludeInTopPicksInt", TypeCode.Byte)
        Dim test11 As New Parameter("ActiveProductInt", TypeCode.Byte)

        test1.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedValue
        test2.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text
        test3.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewIssueAges"), TextBox).Text
        test4.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text
        test5.DefaultValue = Utils.NumOrNull(CType(TPAnnuity_GridView.FooterRow.FindControl("NewAgentFYC"), TextBox).Text)
        test6.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewAgentRenewal"), TextBox).Text
        test7.DefaultValue = Utils.NumOrNull(CType(TPAnnuity_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text)
        test8.DefaultValue = Utils.NumOrNull(CType(TPAnnuity_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text)
        test9.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex
        test10.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex
        test11.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex

        TPAnnuity_SqlDataSource.InsertParameters.Add(test1)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test2)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test3)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test4)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test5)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test6)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test7)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test8)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test9)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test10)
        TPAnnuity_SqlDataSource.InsertParameters.Add(test11)

        TPAnnuity_SqlDataSource.Insert()
    ElseIf e.CommandName = "Update" Then
        TPAnnuity_SqlDataSource.UpdateParameters.Clear()

        Dim param1 As New Parameter("CompanyIDInt", TypeCode.Int32)
        Dim param2 As New Parameter("ProductNameText", TypeCode.String)
        Dim param3 As New Parameter("IssueAgesText", TypeCode.String)
        Dim param4 As New Parameter("PlanTypeNameText", TypeCode.String)
        Dim param5 As New Parameter("AgentFYCInt", TypeCode.Int32)
        Dim param6 As New Parameter("AgentRenewalInt", TypeCode.String)
        Dim param7 As New Parameter("ContractPointsDec", TypeCode.Decimal)
        Dim param8 As New Parameter("BonusPointsInt", TypeCode.Decimal)
        Dim param9 As New Parameter("IncludeInSummaryInt", TypeCode.Int32)
        Dim param10 As New Parameter("IncludeInTopPicksInt", TypeCode.Int32)
        Dim param11 As New Parameter("ActiveProductInt", TypeCode.Int32)
        Dim param12 As New Parameter("AnnuityTotalPointsIDInt", TypeCode.Int32)

        param1.DefaultValue = CType(e.CommandSource.FindControl("EditACompanyID"), DropDownList).SelectedValue
        param2.DefaultValue = CType(e.CommandSource.FindControl("EditAProductName"), TextBox).Text
        param3.DefaultValue = CType(e.CommandSource.FindControl("EditAIssueAges"), TextBox).Text
        param4.DefaultValue = CType(e.CommandSource.FindControl("EditAPlanTypeName"), TextBox).Text
        param5.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditAAgentFYC"), TextBox).Text)
        param6.DefaultValue = CType(e.CommandSource.FindControl("EditAAgentRenewal"), TextBox).Text
        param7.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditAContractPoints"), TextBox).Text)
        param8.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditABonusPoints"), TextBox).Text)
        param9.DefaultValue = CType(e.CommandSource.FindControl("EditAIncludeInSummary"), DropDownList).SelectedIndex
        param10.DefaultValue = CType(e.CommandSource.FindControl("EditAIncludeInTopPicks"), DropDownList).SelectedIndex
        param11.DefaultValue = CType(e.CommandSource.FindControl("EditAActiveProduct"), DropDownList).SelectedIndex
        param12.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditAAnnuityTotalPointsID"), Label).Text)

        TPAnnuity_SqlDataSource.UpdateParameters.Add(param1)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param2)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param3)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param4)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param5)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param6)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param7)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param8)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param9)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param10)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param11)
        TPAnnuity_SqlDataSource.UpdateParameters.Add(param12)

        TPAnnuity_SqlDataSource.Update()
    End If
End Sub

NOT WORKING CODE

    <!-- Total Points Life -->      
        <asp:Panel ID="TPLife_Panel" runat="server" visible="false">
            <hr />
                <table>
                    <tr>
                        <td>Search on </td>
                        <td>
                            <asp:DropDownList ID="TPLife_search_dropdown" runat="server">
                                <asp:ListItem Text="Company" Value="Company"></asp:ListItem>
                                <asp:ListItem Text="Company ID" Value="CompanyID"></asp:ListItem>
                                <asp:ListItem Text="Product Name" Value="ProductName"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td> for </td>
                        <td>
                            <asp:TextBox ID="TPLife_search_Text" runat="server"></asp:TextBox>
                        </td>
                        <td>
                            <asp:Button ID="TPLife_search_Button" runat="server" Text="Search" OnClick="TPLife_search_Click" CssClass="buttonstyle" onmouseover="shade(this);" onmouseout="unshade(this);" />
                        </td>
                    </tr>
                </table>    
                <asp:GridView ID="TPLife_GridView" AllowSorting="true" AllowPaging="true" Runat="server"
                    DataSourceID="TPLife_SqlDataSource" DataKeyNames="LifeTotalPointsID" 
                    AutoGenerateColumns="False" ShowFooter="true" PageSize="20">
                    <Columns>               
                    <asp:TemplateField HeaderText="ID" visible="False" InsertVisible="False" SortExpression="LifeTotalPointsID" HeaderStyle-VerticalAlign="Bottom">
                        <ItemTemplate>
                            <asp:Label ID="Label0" runat="server" Text='<%# Bind("LifeTotalPointsID") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="EditLLifeTotalPointsID" runat="server" Text='<%# Bind("LifeTotalPointsID") %>'></asp:Label>
                        </EditItemTemplate>
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Company" SortExpression="CompanyName" HeaderStyle-VerticalAlign="Bottom">
                        <ItemTemplate>
                            <asp:Label ID="Label11" runat="server" Text='<%# Bind("CompanyName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="EditLCompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName" selectedValue='<%# Bind("CompanyID") %>'></asp:DropDownList>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:DropDownList ID="NewCompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName"></asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="NewCompanyID" Display="Dynamic"  ForeColor="" ErrorMessage="You must enter a value. *" Enabled="false"></asp:RequiredFieldValidator>
                        </FooterTemplate>
                        <FooterStyle Wrap="False" />
                    </asp:TemplateField>

                    <etc I ran out of room>

                    <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ></asp:LinkButton>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:LinkButton ID="lbUpdate" runat="server" CausesValidation="False" CommandName="Update" Text="Update" ></asp:LinkButton>
                        <asp:LinkButton ID="lbCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:LinkButton ID="lbInsert" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" ></asp:LinkButton>
                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Reset"></asp:LinkButton>
                    </FooterTemplate>
                </asp:TemplateField>

                    </Columns>
                </asp:GridView>

                <asp:SqlDataSource ID="TPLife_SqlDataSource" Runat="server"
                    SelectCommand="SELECT * FROM tblTotalPointsLife a left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
                    InsertCommand="INSERT INTO [tblTotalPointsAnnuity](CompanyID, ProductName, PlanTypeName, StandardAgtFYC, StandardFYCExcess, StandardRenewal, PreferredAgtFYC, PreferredFYCExcess, PreferredRenewal, ContractPoints, BonusPoints, IncludeInSummary, IncludeInTopPicks, ActiveProduct) VALUES(@LCompanyIDInt, @LProductNameText, @LPlanTypeNameText, @LStandardAgtFYCInt, @LStandardFYCExcessInt, @LStandardRenewalInt, @LPreferredAgtFYCInt, @LPreferredFYCExcessInt, @LPreferredRenewalInt, @LContractPointsDec, @LBonusPointsInt, @LIncludeInSummaryInt, @LIncludeInTopPicksInt, @LActiveProductInt) "
                    UpdateCommand="UPDATE [tblTotalPointsAnnuity] Set CompanyID = @LCompanyIDInt, ProductName = @LProductNameTest = @LProductNameText, IssueAges = @LIssueAgesText, PlanTypeName = @LPlanTypeNameText, StandardAgtFYC = @LStandardAgtFYCInt, StandardFYCExcess = @LStandardFYCExcessInt, StandardRenewal = @LStandardRenewalInt, PreferredAgtFYC = @LPreferredAgtFYCInt, PreferredFYCExcess = @LPreferredFYCExcessInt, PreferredRenewal = @LPreferredRenewalInt, ContractPoints = @LContractPointsDec, BonusPoints = @LBonusPointsInt, IncludeInSummary = @LIncludeInSummaryInt, IncludeInTopPicks = @LIncludeInTopPicksInt, ActiveProduct = @LActiveProductInt WHERE [LifeTotalPointsID] = @LLifeTotalPointsIDInt">
                    <InsertParameters>
                        <asp:Parameter Name="LCompanyIDInt" Type="Int32" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="LCompanyIDInt" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
        </asp:Panel>
<!-- END Total Points Life -->

NOT WORKING CODE BEHIND

Sub TPLife_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles TPLife_GridView.RowCommand
    Dim TPLife_searchStr As String = TPLife_search_Text.Text

    If TPLife_searchStr = "" Then
        TPLife_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsLife a " & _
                                        " left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
                                        " ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
    Else
        TPLife_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsLife a " & _
                                        " left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
                                    "WHERE 1=1 "

        If TPLife_search_dropdown.SelectedValue = "Company" Then
            TPLife_SqlDataSource.SelectCommand &= " AND ci.CompanyName like '%" & TPLife_search_Text.Text & "%' OR ci.CompanyCode like '%" & TPLife_search_Text.Text & "%'"
        Else If TPLife_search_dropdown.SelectedValue = "CompanyID" Then
            TPLife_SqlDataSource.SelectCommand &= " AND ci.CompanyID = " & TPLife_search_Text.Text
        Else
            TPLife_SqlDataSource.SelectCommand &= " AND " & TPLife_search_dropdown.SelectedValue & " like '%" & TPLife_search_Text.Text & "%' "
        End If
        TPLife_SqlDataSource.SelectCommand &= " ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
    End If

    If e.CommandName = "Cancel" Then
        CType(TPLife_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedIndex = 0
        CType(TPLife_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewStandardAgtFYC"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewStandardFYCExcess"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewStandardRenewal"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewPreferredAgtFYC"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewPreferredFYCExcess"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewPreferredRenewal"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text = ""
        CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex = 0
        CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex = 0
        CType(TPLife_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex = 0
    ElseIf e.CommandName = "Insert" Then
        TPLife_SqlDataSource.InsertParameters.Clear()

        Dim test1 As New Parameter("LCompanyIDInt", TypeCode.Int32)
        Dim test2 As New Parameter("LProductNameText", TypeCode.String)
        Dim test3 As New Parameter("LPlanTypeNameText", TypeCode.String)
        Dim test4 As New Parameter("LStandardAgtFYCInt", TypeCode.Int32)
        Dim test5 As New Parameter("LStandardFYCExcessInt", TypeCode.Int32)
        Dim test6 As New Parameter("LStandardRenewalInt", TypeCode.Int32)
        Dim test7 As New Parameter("LPreferredAgtFYCInt", TypeCode.Int32)
        Dim test8 As New Parameter("LPreferredFYCExcessInt", TypeCode.Int32)
        Dim test9 As New Parameter("LPreferredRenewalInt", TypeCode.Int32)
        Dim test10 As New Parameter("LContractPointsDec", TypeCode.Decimal)
        Dim test11 As New Parameter("LBonusPointsInt", TypeCode.Decimal)
        Dim test12 As New Parameter("LIncludeInSummaryInt", TypeCode.Byte)
        Dim test13 As New Parameter("LIncludeInTopPicksInt", TypeCode.Byte)
        Dim test14 As New Parameter("LActiveProductInt", TypeCode.Byte)

        test1.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedValue
        test2.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text
        test3.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text
        test4.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewStandardAgtFYC"), TextBox).Text)
        test5.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewStandardFYCExcess"), TextBox).Text)
        test6.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewStandardRenewal"), TextBox).Text)
        test7.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewPreferredAgtFYC"), TextBox).Text)
        test8.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewPreferredFYCExcess"), TextBox).Text)
        test9.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewPreferredRenewal"), TextBox).Text)
        test10.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text)
        test11.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text)
        test12.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex
        test13.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex
        test14.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex

        TPLife_SqlDataSource.InsertParameters.Add(test1)
        TPLife_SqlDataSource.InsertParameters.Add(test2)
        TPLife_SqlDataSource.InsertParameters.Add(test3)
        TPLife_SqlDataSource.InsertParameters.Add(test4)
        TPLife_SqlDataSource.InsertParameters.Add(test5)
        TPLife_SqlDataSource.InsertParameters.Add(test6)
        TPLife_SqlDataSource.InsertParameters.Add(test7)
        TPLife_SqlDataSource.InsertParameters.Add(test8)
        TPLife_SqlDataSource.InsertParameters.Add(test9)
        TPLife_SqlDataSource.InsertParameters.Add(test10)
        TPLife_SqlDataSource.InsertParameters.Add(test11)
        TPLife_SqlDataSource.InsertParameters.Add(test12)
        TPLife_SqlDataSource.InsertParameters.Add(test13)
        TPLife_SqlDataSource.InsertParameters.Add(test14)

        TPLife_SqlDataSource.Insert() ***FAILS ON THIS LINE***
    ElseIf e.CommandName = "Update" Then
        TPLife_SqlDataSource.UpdateParameters.Clear()

        Dim param1 As New Parameter("LCompanyIDInt", TypeCode.Int32)
        Dim param2 As New Parameter("LProductNameText", TypeCode.String)
        Dim param3 As New Parameter("LPlanTypeNameText", TypeCode.String)
        Dim param4 As New Parameter("LStandardAgtFYCInt", TypeCode.Int32)
        Dim param5 As New Parameter("LStandardFYCExcessInt", TypeCode.Int32)
        Dim param6 As New Parameter("LStandardRenewalInt", TypeCode.Int32)
        Dim param7 As New Parameter("LPreferredAgtFYCInt", TypeCode.Int32)
        Dim param8 As New Parameter("LPreferredFYCExcessInt", TypeCode.Int32)
        Dim param9 As New Parameter("LPreferredRenewalInt", TypeCode.Int32)
        Dim param10 As New Parameter("LContractPointsDec", TypeCode.Decimal)
        Dim param11 As New Parameter("LBonusPointsInt", TypeCode.Decimal)
        Dim param12 As New Parameter("LIncludeInSummaryInt", TypeCode.Byte)
        Dim param13 As New Parameter("LIncludeInTopPicksInt", TypeCode.Byte)
        Dim param14 As New Parameter("LActiveProductInt", TypeCode.Byte)
        Dim param15 As New Parameter("LLifeTotalPointsIDInt", TypeCode.Int32)

        param1.DefaultValue = CType(e.CommandSource.FindControl("EditLCompanyID"), DropDownList).SelectedValue
        param2.DefaultValue = CType(e.CommandSource.FindControl("EditLProductName"), TextBox).Text
        param3.DefaultValue = CType(e.CommandSource.FindControl("EditLPlanTypeName"), TextBox).Text
        param4.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLStandardAgtFYC"), TextBox).Text)
        param5.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLStandardFYCExcess"), TextBox).Text)
        param6.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLStandardRenewal"), TextBox).Text)
        param7.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLPreferredAgtFYC"), TextBox).Text)
        param8.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLPreferredFYCExcess"), TextBox).Text)
        param9.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLPreferredRenewal"), TextBox).Text)
        param10.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLContractPoints"), TextBox).Text)
        param11.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLBonusPoints"), TextBox).Text)
        param12.DefaultValue = CType(e.CommandSource.FindControl("EditLIncludeInSummary"), DropDownList).SelectedIndex
        param13.DefaultValue = CType(e.CommandSource.FindControl("EditLIncludeInTopPicks"), DropDownList).SelectedIndex
        param14.DefaultValue = CType(e.CommandSource.FindControl("EditLActiveProduct"), DropDownList).SelectedIndex
        param15.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLLifeTotalPointsID"), Label).Text)

        TPLife_SqlDataSource.InsertParameters.Add(param1)
        TPLife_SqlDataSource.InsertParameters.Add(param2)
        TPLife_SqlDataSource.InsertParameters.Add(param3)
        TPLife_SqlDataSource.InsertParameters.Add(param4)
        TPLife_SqlDataSource.InsertParameters.Add(param5)
        TPLife_SqlDataSource.InsertParameters.Add(param6)
        TPLife_SqlDataSource.InsertParameters.Add(param7)
        TPLife_SqlDataSource.InsertParameters.Add(param8)
        TPLife_SqlDataSource.InsertParameters.Add(param9)
        TPLife_SqlDataSource.InsertParameters.Add(param10)
        TPLife_SqlDataSource.InsertParameters.Add(param11)
        TPLife_SqlDataSource.InsertParameters.Add(param12)
        TPLife_SqlDataSource.InsertParameters.Add(param13)
        TPLife_SqlDataSource.InsertParameters.Add(param14)
        TPLife_SqlDataSource.InsertParameters.Add(param15)

        TPLife_SqlDataSource.Update() ***FAILS ON THIS LINE***
    End If
End Sub

I've tried comparing both front & back codes, and can't see the issue. I've tried making the 2nd panel visible by default, and it doesn't change anything. The reset function works fine on the 2nd grid, but the insert and update commands don't.


Answer:

You should change these lines

TPAnnuity_SqlDataSource.InsertParameters.Add(testN)

to

TPLife_SqlDataSource.InsertParameters.Add(testN)

EDIT

You forgot to change the table name of the asp:SqlDataSource INSERT and UPDATE commands from tblTotalPointsAnnuity to tblTotalPointsLife


Related:


Difference between application and module pipelines in Nancy?


c#,asp.net,nancy
I have seen in the documentation of Nancy, sometimes these two are referred distinctively. And also is there a difference in the Before/After hooks of these two pipelines?...

The column name “FirstName” specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument


sql,sql-server,sql-server-2008
I am getting the following error message when I am trying to do replace null to zero. The column name "jan" specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument. Query below: select * from(select isnull(jan,0),isnull(feb,0),sum(data) as amount )as p pivot( sum(amount) for month...

Title search in SQL With replacement of noice words [on hold]


sql,sql-server,sql-server-2008
I have Two tables first us IMG_detail S.NO Title 1 women holding stack of gifts 2 Rear view of a man playing golf 3 Women holding gifts 4 Close-up of a golf ball on a tee 5 Businessman reading a newspaper and smiling and Second is tbl_NoiceWords SN Key 1...

for-loop add columns using SQL in MS Access


sql,ms-access,table,for-loop,iteration
I am trying to add n columns to a table, like in this example of code where n = 10: Sub toto() Dim db As Database, i As Integer Set db = CurrentDb() For i = 1 To i = 10 db.Execute " ALTER TABLE time_series " _ & "ADD...

onSuccess and onFailure doesn't get fired


javascript,c#,asp.net,webmethod,pagemethods
I have used onSuccess and onFailure in my PageMethod call. However neither of them gets called and the WebMethod doesn't get fired either. alert("1"); PageMethods.LoginUser(onSuccess, onFailure, email, pass); alert("2"); function onSuccess(val) { } function onFailure() { } [WebMethod(EnableSession = true)] public static int LoginUser(string email, string pass) { //Doesn't get...

SQL Customized search with special characters


sql,sql-server,sql-server-2008
I am creating a key-wording module where I want to search data using the comma separated words.And the search is categorized into comma , and minus -. I know a relational database engine is designed from the principle that a cell holds a single value and obeying to this rule...

MySQL: Select several rows based on several keys on a given column


mysql,sql,database
I have this mysql table structure: ------------------------------------ | item_id | meta_key | meta_value | ------------------------------------ 159 category Bungalow 159 location Lagos 159 price 45000 160 category Bungalow 160 location Abuja 160 price 53500 ... 350 category Bungalow 350 location Lagos 350 price 32000 What I'd like to do is select...

Unable to find the auto created Database


c#,asp.net,asp.net-mvc,entity-framework
I have created simple ASP.NET MVC4 application using EntityFramework Code first approach. The entity class is as below: public class Album { [Key] public int AblumId { get; set; } public decimal Price { get; set; } public string Title { get; set; } } public class MusicContext : DbContext...

SQL Multiple LIKE Statements


sql,sql-server,tsql,variables,like
I'm currently working on a report that shows me all post codes covered by our sales team. Each team covers over 100 post codes. What i would like to do is create a report that brings back the clients within the post code. Currently my code looks like this. SELECT...

SQL varchar variable inserts question mark


sql,sql-server-2012
I've a database value that when inserted into a SQL variable, shows with question mark at the end !! can't find a reason?! declare @A varchar(50) = 'R2300529‏' select @A Results: R2300529? any explanation? i'm using SQL server 2012....

Pull information from SQL database and getting login errors


php,sql,database
I am creating a very small, simple CRM for a company, they require the function to be able to view the last 25 orders via the dashboard. The orders are added via a Order-add form within the CRM. When adding the following code to the CRM I get an error:...

System.net.http.formatting causing issues with Newtonsoft.json


c#,asp.net,asp.net-mvc,json.net
My Windows service is in the same solution as a MVC project. The MVC project uses a reference to SignalR Client which requires Newtonsoft.Json v6 + the Windows service uses System.Net.Http.Formatting, which requires Newtonsoft.Json version 4.5.0.0. I assumed this would not be a problem, as I could just use a...

Inner Join 3 tables pl/sql


mysql,sql
Basically i want to inner join 3 tables and the case is understood by the query itself as follows. Tables: A has 2 columns column 1 and column 2 B has 2 columns column 3 and column 4 C has 3 columns column 5,column 6 and column 7 Query: select...

How to join result of a Group by Query to another table


sql,tsql
I have the following Group By SQL: SELECT s.Login_Name, COUNT(s.s1CIDNumber) FROM [dbSuppHousing].[dbo].[tblSurvey] s group by s.Login_Name I want to know how I can join this result set to another table(tblUsers) to add user_id to the result set (tblSurvey and tblUsers have 1-1 relationship on Login_Name) I tried the following: Select...

How do I find records in one table that do exist in another but based on a date?


mysql,sql
I want to find all the dealers who haven't had an order in 2015 yet. I know this query doesn't work but I thought it might be helpful to understand what I want to do. In this example I want to get just "Bob" as a result. He is the...

Catch concurrency exception in EF6 to change message to be more user friendly


c#,asp.net,.net,entity-framework,entity-framework-6
I am using EF6.1 and i would like to change the message to a more system specific message when the below exception is thrown. Store update, insert, or delete statement affected an unexpected number of rows (0) Now, my problem is i cannot seem to catch the exception? I have...

Query how often an event occurred at a given time


mysql,sql
[Aim] We would like to find out how often an event "A" ocurred before time "X". More concretely, given the dataset below we want to find out the count of the prior purchases. [Context] DMBS: MySQL 5.6 We have following dataset: user | date 1 | 2015-06-01 17:00:00 2 |...

T-SQL Ordering a Recursive Query - Parent/Child Structure


sql,tsql,recursion,order,hierarchy
I am trying (and failing) to correctly order my recursive CTE. My table consists of a parent-child structure where one task can relate to another on a variety of different levels. For example I could create a task (this is the parent), then create a sub-task from this and then...

Convert Double from String


asp.net,vb.net,visual-studio-2012,converter
When converting string to floating, the converter creates wrong results. ?Global.System.Convert.ToDouble("635705821821928755").ToString("0") "635705821821929000" ?Global.System.Convert.ToSingle("635705821821928755").ToString("0") "635705800000000000" I am working with VB.Net Visual Studio 2012, Framework 4 on ASP.Net Webpage. Is there any solution for converting huge numbers from string into floating?...

Retrieve Values As Column


mysql,sql
I've the following table in my PHPMYADMIN The desired output is headline                              impressions              clicks Buy A new Iphone                 ...

oracle sql error Case When Then Else


sql,oracle,oracle11g
SELECT * FROM FirstTable WHERE RowProcessed = 'N' AND ( CASE WHEN EXISTS(SELECT top 1 FROM SecondTable) THEN 1 ELSE EXISTS( SELECT SecondTable.RowProcessed FROM SecondTable WHERE FirstTable.Key = SecondTable.Key AND SecondTable.RowProcessed = 'Y' ) END ) AND OtherConditions Case When then else in where clause. Not sure about the syntax....

Select Statement on Two different views


sql
I couldn't find the answer to my specific question anywhere. Is it possible to select from two different views? For example my code looks something like this right. select view1.col1, view1.col2, view1.col3 from dbo.view1 inner join ~~~~~ inner join ~~~~~ but I want to include a column from a different...

WCF service architecture query


asp.net,architecture,wcfserviceclient
I have an application that consists of a web application, and mutliple windows services, only one windows service is installed depending on what version of the backend sofware is used. Currently, Data is saved by the web app in a database, then the relevant service is installed and this picks...

Purging Database - Count purged/not-purged tables


mysql,sql,sql-server,database,stored-procedures
So I am working with a database where I will be purging various tables that contain rows that are older than 30days. I have fairly limited knowledge of SQL and wanted to know if there was a certain way to select the row that will be purged and the rows...

Default the year based on month value


sql,sql-server
I have a query to display the year value from a table and default the current year. select distinct year(startdate) as syear, year(startdate) as eyear, 1 as sOrder from [TTS].[dbo].[Class] where year(startdate) <> year(getdate()) union all select year(getdate()) as syear, year(getdate()) as eyear, 0 as sOrder order by sOrder asc,...

mysql_real_escape_string creates \ in server only not in local


php,sql
When I use mysql_real_escape_string in my localhost and I output the result of html in a table I have no problem. But when I use it on my server it outputs even the \ This is how I use it: $_GETVARS['txtEmpNum'] = mysql_real_escape_string($_GETVARS['txtEmpNum']); $_GETVARS['txtLName'] = mysql_real_escape_string($_GETVARS['txtLName']); $_GETVARS['txtFName'] = mysql_real_escape_string($_GETVARS['txtFName']); $varSQL...

deployment of a site asp.net and iis


c#,asp.net,iis
I know this is for some of you a stupid question but for me is a real problem. I have never deployed a site before What i have done so far: 1) publish the site from visual studio to a folder. 2) added to iis for testing everything works great...

SQL Server / C# : Filter for System.Date - results only entries at 00:00:00


c#,asp.net,sql-server,date,gridview-sorting
I have a connected SQL Server database in Visual Studio and am displaying its content in a grid. I created a dropdown menu with the column names as selectable options and a text field to filter for specific content, e.g., DropDown = "Start" - Textfield = 14.03.2015 = Filter Column...

Can someone explain to me how this statement is an exclude?


sql,sql-server,tsql
Can someone tell me how this is an exclude? Assuming that tableID is auto generated and in columnY there can be value of 0 or 1. This statement should exclude everything were columnY has a value of 1. SELECT * FROM [table].[dbo].[one] AS t1 LEFT JOIN [table].[dbo].[one] AS t2 ON...

Is there a better way to write this query involving a self select?


sql,postgresql,join,aggregate-functions
I am looking for a "better" way to perform a query in which I want to show a single player who he has played previously and the associated win-loss record for each such opponent. Here are the tables involved stripped down to essentials: create table player (player_id int, username text);...

Access manager information from Active Directory


c#,asp.net,active-directory
Attach is the picture of active directory, which i got from my IT department. Now i want to get the manager information in C#. NOTE: I am able to get all information of user but there isn't any key of manager, but IT department just gave me above attached...

Creating a viewmodel on an existing project


c#,asp.net,asp.net-mvc
I am trying to add a viewmodel to a project because I want my view to use two separate models. I've looked at different tutorials trying to learn how to do this but I am having some trouble. Before, the view was strongly binded(typed?) to the Person model, but now...

SQL: overcoming no ORDER BY in nested query


sql,sqlite
I have a table t as follows: CREATE TABLE t( id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT, a TEXT, b TEXT ); Sample Data 1|2015-06-15|a1 15|b1 15 2|2015-06-15|a2 15|b2 15 3|2015-06-16|a1 16|b1 16 4|2015-06-16|a2 16|b2 16 5|2015-06-17|a1 17|b1 17 6|2015-06-17|a2 17|b2 17 I want to select all values of a...

Fastest way to add a grouping column which divides the result per 4 rows


sql,sql-server,tsql,sql-server-2012
If i have a resultset like this for example (just a list of numbers) : 1,2,3,4,5,6,7,8,9,10,11 and I would like to add a grouping column so i can group them per 4 like this : 1,1,1,1,2,2,2,2,3,3,3 (The last one in this examle does not have a forth element, so that...

Select count Columns group by No


sql,sql-server
Emp_No Emp_Shift Emp_Date 500 AL 1/5/2015 600 S 2/5/2015 600 H 3/5/2015 500 S 4/5/2015 500 AL 5/5/2015 600 AL 6/5/2015 I need help on this issue , HOW TO RETURN count in 3 Columns >> EX: Emp_No Count Al Count S Count H 500 2 1 0 600 1...

Take thousand value in SQL


sql,sql-server
I have values like below I need to take only the thousand value in sql. 38,635.123 90,232.89 123,456.47888 I need to take result as below. 635 232 456...

left join table, find both null and match value


sql,sql-server,join
I have two 2 table t1(years int, numOfppl int), t2(years int, numOfppl int). t1 contains years between 2001 and 2010 , t2 contains years between 2003-2005 and 2007-2010 I want to query a result like that t1.years t1.numOfppl t2.yeras t2.numOfppl 2001 7 null null 2002 6 null null 2003 4...

Convert AWK command to sqlite query


sql,awk,sqlite3
I have to parse very big (abt 40Gb) text files(logs) very often. Usually AWK/grep is enough for my needs, but logs are growing and now I'm curious whether sqlite3 will allow me to do the same things more efficiently. I chosen sqlite for my tests as it installed out-of-the-box (SQLite...

SQL Group By multiple categories


php,mysql,sql,mysqli
This is the query I'm using to count how many events are booked for each category of bookings. SELECT Categories.name, count(case when locations.name ='loc 1' then 1 end) as Location1, count(case when locations.name ='loc 2' then 1 end) as Location2, count(case when locations.name ='loc 3' then 1 end) as Location3,...

How to select next row after select in SQL Server?


sql,sql-server
I have this issue, I need your help: EmpNo Shift_Date Shift1 shift2 stamp_Date stamp_Time stamp_Type 426 2015-04-12 A 2015-04-12 10:09:00.000 I 426 2015-04-15 B C 2015-04-15 23:46:00.000 I 426 2015-04-15 B C 2015-04-15 23:45:00.000 O 426 2015-04-16 OF 2015-04-16 07:02:00.000 O 426 2015-04-17 A 2015-04-17 07:34:00.000 I 426 2015-04-18 A...

Show/hide tinymce with radio buttons


c#,asp.net,asp.net-mvc,tinymce
I try to show/hide a tinymce with radobutton. Like yes/no. So there are two radio buttons. yes - will show the tiny mce and no will hide the tinymce. I have this: showing tiny mce: <div class="form-group"> @Html.Label(Resources.Entity.Product.PdfMessage, new { @class = "text-bold control-label col-md-2" }) <div class="col-lg-6 col-md-8 col-sm-10...

Add 1 to datediff result if time pass 14:30 or 2:30 PM


sql,ms-access,ms-access-2007
Here is my SQL query which returns number of days by subtracting current date from specified date and returns exact as i need, but in addition i want to add 1 to result if current time passes 14:30 or 2:30. My query SELECT reservations.customerid, DateDiff("d",reservations.checkin_date,Now()) AS Due_nights FROM reservations Am...

SQL Repeated Condition in Two Tables


sql,variables,coding-style,condition
I am a beginner to SQL, and I am having trouble getting rid of repeated code. I have a condition "AccountId=20" that I use twice in a SQL query. The SQL looks something like: DELETE FROM Table_A WHERE FunctionId IN (Select FunctionId FROM Table_B WHERE AccountId=20); DELETE FROM Table_B WHERE...

Using Sum in If in Mysql


mysql,sql,select,sum
I want to select the sum of values of my_field. The unit of my_field is in seconds. I don't want to exceed 24 hours, so when it exceeds 24 hours, I want it to select 24*60*60 = 86400. SELECT IF(SUM(my_field) > 86400, 86400, SUM(my_field)) ... This solution doesn't seem to...

Foreign key in C#


c#,sql,sql-server,database
I have two tables, A and B, in a dataset in SQL Server; I have created a connection to the dataset in a c# project in visual studio. How can I create a foreign key ( A is the parent) between my two tables ? I want to create the...

How to make a website work only with https [duplicate]


asp.net,ssl,https
This question already has an answer here: How to force HTTPS using a web.config file 3 answers How do I make a website to work only with https? Is there any method to make my website work only if the protocol is https? For example let me say http://www.mywebsite.com,...

Get unique row by single column where duplicates exist


sql,sql-server
I have the following DB table called messages with columns: thread_id, sender_id, receiver_id, date Example: +-----------+------------+-------------+-------------+ | thread_id | sender_id | receiver_id | date | +----------------------+-----------+-----------------+ | 1 | 1 | 2 | 11/06/2015 | | 1 | 2 | 1 | 14/06/2015 | | 1 | 1 | 2...

check if file is image


c#,asp.net,asp.net-mvc
I want to check if file is image. and then you will see a link where you can see the image. But the link only has to appear if file is link. I try it like this: if (!String.IsNullOrEmpty(item.FileName)) { var file = item.FileName; string[] formats = new string[] {...

Matplotlib: Plot the result of an SQL query


python,sql,matplotlib,plot
from sqlalchemy import create_engine import _mssql from matplotlib import pyplot as plt engine = create_engine('mssql+pymssql://**:****@127.0.0.1:1433/AffectV_Test') connection = engine.connect() result = connection.execute('SELECT Campaign_id, SUM(Count) AS Total_Count FROM Impressions GROUP BY Campaign_id') for row in result: print row connection.close() The above code generates an array: (54ca686d0189607081dbda85', 4174469) (551c21150189601fb08b6b64', 182) (552391ee0189601fb08b6b73', 237304) (5469f3ec0189606b1b25bcc0',...

Can I uniquely identify 2 check boxes so that I can add a different image to each?


html,css,asp.net,checkbox
Currently I am using an image for checked and unchecked checkboxes the html and css is below. <div class="text-field-box text-field-box-mobile radio-button-box small"> <asp:CheckBox ID="ChkOffer1" text=" " runat="server" class="checkbox checkbox-mobile radio" Visible="true" EnableViewState="true"></asp:CheckBox> <% Response.Write(Session("Offer1"))%> </div> and css input[type=checkbox] { display:none; } input[type=checkbox] + label { background-image: url("checkbox-default.png"); background-repeat: no-repeat;...