Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8197509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:45:22+00:00 2026-06-07T05:45:22+00:00

I have encountered this error: Must declare the scalar variable @UserId when i am

  • 0

I have encountered this error: Must declare the scalar variable “@UserId” when i am trying to delete one particular row in my SqlServer. I had already declare the UserId in the DeleteParameters, but this error still appear.

Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable > "@UserId".

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Here is my code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" 
    SelectCommand="SELECT aspnet_Membership.Email, Details.CustName, Details.CustNum, Details.CustRole, Details.CustStatus, Details.PName, Details.PEmail, Details.PRole, Details.WedDate, aspnet_Users.UserName, Details.UserId FROM Details INNER JOIN aspnet_Membership ON Details.UserId = aspnet_Membership.UserId INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId WHERE (Details.UserId = @UserId)"
    UpdateCommand="update Details SET CustName = @CustName, CustNum = @CustNum, CustRole = @CustRole, CustStatus = @CustStatus, PName = @PName, PEmail = @PEmail, PRole = @PRole, WedDate = @WedDate WHERE [UserId] = @UserId Update aspnet_Membership Set Email= @email WHERE [UserId] = @UserId"
    DeleteCommand="DELETE FROM Details WHERE [UserId] = @UserId">
    <DeleteParameters>
        <asp:Parameter Name="UserId" type="String" />
        <asp:Parameter Name="CustName" />
        <asp:Parameter Name="CustNum" />
        <asp:Parameter Name="CustRole" />
        <asp:Parameter Name="CustStatus" />
        <asp:Parameter Name="PName" />
        <asp:Parameter Name="PEmail" />
        <asp:Parameter Name="PRole" />
        <asp:Parameter Name="WedDate" />
        <asp:Parameter Name="email" />
    </DeleteParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="lblHidden" Name="UserId"
        PropertyName="Text" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="CustName" />
        <asp:Parameter Name="CustNum" />
        <asp:Parameter Name="CustRole" />
        <asp:Parameter Name="CustStatus" />
        <asp:Parameter Name="PName" />
        <asp:Parameter Name="PEmail" />
        <asp:Parameter Name="PRole" />
        <asp:Parameter Name="WedDate" />
        <asp:Parameter Name="UserId" />
        <asp:Parameter Name="email" />
    </UpdateParameters>
</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server"
    AutoGenerateRows="False" DataSourceID="SqlDataSource1"
    Height="50px" Width="125px">
    <Fields>
        <asp:BoundField DataField="Email" HeaderText="Email"
            SortExpression="Email" />
        <asp:BoundField DataField="CustName" HeaderText="CustName"
            SortExpression="CustName" />
        <asp:BoundField DataField="CustNum" HeaderText="CustNum"
            SortExpression="CustNum" />
        <asp:BoundField DataField="CustRole" HeaderText="CustRole"
            SortExpression="CustRole" />
        <asp:BoundField DataField="CustStatus" HeaderText="CustStatus"
            SortExpression="CustStatus" />
        <asp:BoundField DataField="PName" HeaderText="PName"
            SortExpression="PName" />
        <asp:BoundField DataField="PEmail" HeaderText="PEmail"
            SortExpression="PEmail" />
        <asp:BoundField DataField="PRole" HeaderText="PRole"
            SortExpression="PRole" />
        <asp:BoundField DataField="WedDate" HeaderText="WedDate"
            SortExpression="WedDate" />
        <asp:BoundField DataField="UserName" HeaderText="UserName"
            SortExpression="UserName" />
        <asp:BoundField DataField="UserId" HeaderText="UserId"
            SortExpression="UserId" />
        <asp:CommandField ShowDeleteButton="True"
            ShowEditButton="True" />
    </Fields>
</asp:DetailsView>
<asp:Label ID="lblHidden" runat="server" Text="Label" Visible="False">
</asp:Label>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:45:24+00:00Added an answer on June 7, 2026 at 5:45 am

    I think you have pasted T-SQL query as it was. I want to explain you what you are doing here:

    SELECT aspnet_Membership.Email, Details.CustName, Details.CustNum, 
        Details.CustRole, Details.CustStatus, Details.PName, Details.PEmail, 
        Details.PRole, Details.WedDate, aspnet_Users.UserName, Details.UserId 
    FROM Details 
    INNER JOIN aspnet_Membership ON Details.UserId = aspnet_Membership.UserId 
    INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId 
    WHERE (Details.UserId = @UserId) 
    

    this query retrieves the data from the following table on the basis of UserId

    1. Details
    2. aspnet_Membership
    3. aspnet_Users

    You have to pass UserId to the SqlDataSource to perform its function: Read about how to INSERT, UPDATE and DELETE with SQLDataSource

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have encountered this error when trying to delete a cell, using a custom
I have encountered this error when trying to push a subrepository to bitbucket: D:\Work\agile.crm.framework>hg
I have encountered this error Fatal error: Class 'PHPExcel_Shared_ZipStreamWrapper' not found in \VBOXSVR\ACACIASOFT\apc\spreadsheet\lib\phpexcel\PHPExcel\Autoloader.php on
I have been trying to fix this for a bit, and I must be
While trying to do an assets:precompile for a production website I've encountered this error
I have encountered this topic lately and couldn't understand why they are needed. Can
I have encountered this problem today and I don't have an explanation for it.
I have browsed lift's MegaProtoUser and encountered this construction: ??(Last Name) . Can anyone
While going through some tutorials, I have encountered lines such as this: ((IDisposable)foo).Dispose(); Ignore
How to write this in C#.NET, I have not been encountered using the ^

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.