locked
Can't query by memberID for some reason RRS feed

  • Question

  • User-56120927 posted

    Hi,

    I'm stuck.  I'm trying to return only a details view for the logged in user on this copy of the member details page.  I create a variable called MemberID on page load and when I use a break, I can see that the correct value is being assigned to the variable.

     However, when I run the page, no details view displays because the query is not executing properly.  Is there anything obviously wrong here?

     Many thanks in advance,

    -JS

    Here is the code:

     

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Modify Membership Details" %>

    <%@ Register TagPrefix="Club" Namespace="ClubSite" %>

    <script runat="server">

     

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

     

    Dim MemberID As String

     

    If Not Page.User.Identity.IsAuthenticated Then

    Response.Write("To use the member details functionality, you need to be authenticated. Please use the <a href='login.aspx'>Login</a> page to authenticate yourself.")

    Response.End()

    End If

    If Not IsPostBack Then

    InitPageData()

    End If

     

    If User.Identity.IsAuthenticated = True Then

    MemberID = Membership.GetUser.ProviderUserKey.ToString()

    End If

     

    End Sub

     

    Sub InitPageData()

    Dim user As MembershipUser = Membership.GetUser()

    Dim da As New DataSetTableAdapters.MemberInfoTableAdapter

    Dim dt As DataSet.MemberInfoDataTable = da.GetMember(CType(user.ProviderUserKey, Guid))

     

    If dt.Rows.Count = 1 Then

    Dim mr As DataSet.MemberInfoRow = dt(0)

    UserName.Text = user.UserName

    End If

     

    End Sub

    </script>

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <div id="body">

    <!--Start of left column-->

    <div id="columnleft">

    <a name="content_start" id="content_start"></a>

    <div class="leftblock">

    <h2>

    <asp:Label ID="UserName" runat="server" />'s Basic Information

    </h2>

    <p>

    <strong>Modify My:</strong></p>

    <p>

    <a href="Member_Details.aspx">

    Membership Details<strong></strong></a></p>

    <p>

    <a href="Member_Artist.aspx">

    Artist Profile</a></p>

    <p>

    <a href="Member_Pro.aspx">

    Professional Profile</a></p>

    <p>

    <a href="Member_Student.aspx">

    Student Profile</a></p>

    </div>

    </div>

    <!--end columnleft-->

    <!--Start of right column-->

    <div id="columnright">

    &nbsp;&nbsp;<br />

    <br />

    <br />

    &nbsp;&nbsp;<br />

    <br />

    <br />

    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="memberid"

    DataSourceID="SqlDataSource1" Height="50px" Width="125px">

    <Fields>

    <asp:BoundField DataField="memberid" HeaderText="memberid" ReadOnly="True" SortExpression="memberid" />

    <asp:BoundField DataField="address" HeaderText="address" SortExpression="address" />

    <asp:BoundField DataField="phone" HeaderText="phone" SortExpression="phone" />

    <asp:BoundField DataField="firstname" HeaderText="firstname" SortExpression="firstname" />

    <asp:BoundField DataField="lastname" HeaderText="lastname" SortExpression="lastname" />

    <asp:BoundField DataField="WhatInspiresStudent" HeaderText="WhatInspiresStudent"

    SortExpression="WhatInspiresStudent" />

    </Fields>

    </asp:DetailsView>

    &nbsp;

    </div>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDb %>" SelectCommand="SELECT memberid, address, phone, firstname, lastname, WhatInspiresStudent FROM MemberInfo WHERE (memberid = @MemberID)">

    <SelectParameters>

    <asp:Parameter Name="MemberID" />

    </SelectParameters>

    </asp:SqlDataSource>

    <div class="clear2column">

    </div>

    </div>

    </asp:Content>

    Friday, November 3, 2006 2:51 AM

All replies

  • User-56120927 posted

    Hi,

    Still having this problem.  Here is a greatly simplified version of the same code above.  I get a "Must declare the scalar variable "@Bozo" error every time.

    Can anyone see what could be wrong here:

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" %>

    <script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

     

    Dim Bozo As String

     

    If User.Identity.IsAuthenticated = True Then

    Bozo = Membership.GetUser.ProviderUserKey.ToString()

    End If

     

    End Sub

    </script>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"

    DataKeyNames="memberid" DataSourceID="SqlDataSource1" Height="50px" Width="125px">

    <Fields>

    <asp:BoundField DataField="memberid" HeaderText="memberid" ReadOnly="True" SortExpression="memberid" />

    <asp:BoundField DataField="firstname" HeaderText="firstname" SortExpression="firstname" />

    <asp:BoundField DataField="lastname" HeaderText="lastname" SortExpression="lastname" />

     

    </Fields>

    </asp:DetailsView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDb %>"

    SelectCommand="SELECT * FROM [MemberInfo] WHERE ([memberid] = @Bozo)">

    <SelectParameters>

    <asp:Parameter DefaultValue="@Bozo" Name="memberid" Type="Object" />

    </SelectParameters>

    </asp:SqlDataSource>

    </asp:Content>

    Thanks in advance for any help![:)]

    -JS

    Sunday, November 19, 2006 5:50 PM