Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Must declare the Variable in ASP.NET

Posted on 2007-03-29
3
Medium Priority
?
376 Views
Last Modified: 2012-08-13
Just a simple Application.  One GridView viewing a table information.  One DetailView viewing details when user clicks on a record on the GridView, and I am getting an error "Must Declare the variable @AffiliateID".  Please HELP!!!.

<table cellpadding=0 cellspacing=0 align="center" valign="middle" width="100%" height="93%">
    <tr>
        <td align="left" valign="top">
            <asp:GridView ID="UnapprovedAccountGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                CellPadding="4" DataKeyNames="AffiliateID" DataSourceID="UnApproved_DS" ForeColor="#333333"
                GridLines="None" Width="100%" AllowSorting="True"  >
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:CommandField ShowSelectButton="True" SelectText="Details"/>
                    <asp:BoundField DataField="AffiliateCode" HeaderText="Affiliate Code" ReadOnly="True"
                        SortExpression="AffiliateCode" />
                    <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                    <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                    <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                    <asp:BoundField DataField="EmailAddress" HeaderText="Email Address" SortExpression="EmailAddress" />
                    <asp:BoundField DataField="SignupDate" HeaderText="Signup Date" SortExpression="SignupDate" />
                    <asp:BoundField DataField="SignupIP" HeaderText="Signup IP" SortExpression="SignupIP" />
                    <asp:BoundField DataField="ADTitle" HeaderText="AD Title" SortExpression="ADTitle" />
                    <asp:BoundField DataField="Active" HeaderText="Active" SortExpression="Active" />
                </Columns>
                <RowStyle BackColor="#EFF3FB" />
                <EditRowStyle BackColor="#2461BF" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#507CD1" CssClass="HeaderStyle" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
            <asp:SqlDataSource ID="UnApproved_DS" runat="server" ConnectionString="<%$ ConnectionStrings:Seamless_MainWebConnection %>"
                ProviderName="<%$ ConnectionStrings:Seamless_MainWebConnection.ProviderName %>"
                SelectCommand="SELECT af.AffiliateID,af.AffiliateCode, af.FirstName, af.LastName,
                af.Username, af.EmailAddress, af.SignupDate, af.SignupIP,
                pm.ADTitle, af.Active FROM Affiliate af INNER JOIN Promotion
                pm ON af.PromotionID = pm.PromotionID ORDER BY af.SignupDate DESC">
            </asp:SqlDataSource>
        </td>
    </tr>
    <tr>
        <td>
            <asp:DetailsView ID="UnApprovedAccountDetails" runat="server" AutoGenerateRows="False" CellPadding="4"
                DataSourceID="Unapproved" ForeColor="#333333" GridLines="None" Height="50px"
                Width="268px">
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
                <EditRowStyle BackColor="#2461BF" />
                <RowStyle BackColor="#EFF3FB" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <Fields>
                    <asp:BoundField DataField="AffiliateCode" HeaderText="Affiliate Code" ReadOnly="True"
                        SortExpression="AffiliateCode" />
                    <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                    <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                    <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                    <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
                    <asp:BoundField DataField="EmailAddress" HeaderText="Email Address" SortExpression="EmailAddress" />
                    <asp:BoundField DataField="SignupDate" HeaderText="Signup Date" ReadOnly="True" SortExpression="SignupDate" />
                    <asp:BoundField DataField="SignupIP" HeaderText="Signup IP" ReadOnly="True" SortExpression="SignupIP" />
                    <asp:BoundField DataField="PromotionID" HeaderText="Promotion ID" SortExpression="PromotionID" />
                    <asp:BoundField DataField="Points" HeaderText="Points" ReadOnly="True" SortExpression="Points" />
                    <asp:BoundField DataField="Active" HeaderText="Active" SortExpression="Active" />
                    <asp:BoundField DataField="ActivatedAdminUser" HeaderText="Activated Admin User"
                        ReadOnly="True" SortExpression="ActivatedAdminUser" />
                    <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
                    <asp:CommandField ButtonType="Button" ControlStyle-CssClass="btn" DeleteText="Delete Account" EditText="Edit Affiliate Account"
                        ShowDeleteButton="True" ShowEditButton="True" />
                </Fields>
                <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            </asp:DetailsView>
            <asp:SqlDataSource ID="Unapproved" runat="server" ConnectionString="<%$ ConnectionStrings:Seamless_MainWebConnection %>"
                ProviderName="<%$ ConnectionStrings:Seamless_MainWebConnection.ProviderName %>"
                OldValuesParameterFormatString="original_{0}"
                SelectCommand=" SELECT [AffiliateID],[AffiliateCode], [FirstName], [LastName],
                [Username], [Password], [EmailAddress], [SignupDate], [SignupIP],
                [PromotionID], [Points], [Active], [ActivatedAdminUser], [Notes] FROM
                [Affiliate] WHERE ([AffiliateID] = @AffiliateID)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="UnapprovedAccountGrid" Name="AffiliateID"
                                PropertyName="SelectedIndex" Type="int32" />
                </SelectParameters>
            </asp:SqlDataSource>
           
        </td>
    </tr>
</table>
0
Comment
Question by:ResortCompanies
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
rboyd56 earned 1000 total points
ID: 18820922
This variable, @AffiliateID, is being passed to the last select statement:

SELECT [AffiliateID],[AffiliateCode], [FirstName], [LastName],
                [Username], [Password], [EmailAddress], [SignupDate], [SignupIP],
                [PromotionID], [Points], [Active], [ActivatedAdminUser], [Notes] FROM
                [Affiliate] WHERE ([AffiliateID] = @AffiliateID)

Where is it being declared and assigned a value?
0
 

Author Comment

by:ResortCompanies
ID: 18820931
As far as I know:

<SelectParameters>
                    <asp:ControlParameter ControlID="UnapprovedAccountGrid" Name="AffiliateID"
                                PropertyName="SelectedIndex" Type="int32" />
                </SelectParameters>

Unless I am suppose to declare somewhere else?
0
 

Author Comment

by:ResortCompanies
ID: 18821059
I have found the answer myself.  SQL statement should be "WHERE AffiliateID = ?" rather then " = @AffiliateID"
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question