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

  • Home
  • SEARCH
  • 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 6032477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:20:24+00:00 2026-05-23T05:20:24+00:00

I am trying to insert checkboxlist values into SQL Server using a stored procedure.

  • 0

I am trying to insert checkboxlist values into SQL Server using a stored procedure. I’m getting this error

Item In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.

Here’s my stored procedure:

ALTER PROCEDURE [dbo].[usp_insertquestionnarie] 
    (@interestid int)

    INSERT INTO [a_abacus].[dbo].[joininterest]
    VALUES (@interestid)

Here’s my vb code:

 Protected Sub cmdsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdsubmit.Click

        Dim strConnString As String = WebConfigurationManager.ConnectionStrings("a_abacus").ConnectionString
        Dim con As New SqlConnection(strConnString)
        Dim cmd As New SqlCommand("usp_insertquestionnarie", con) 'references connectionstring and calls store procedure'
        cmd.CommandType = Data.CommandType.StoredProcedure 'sets default to be stored procedure'
        lblmessage.Text = String.Empty

        Dim Item As ListItem
        lblMessage.Text = ""
        For Each Item In chkboxinterest.Items
            If Item.Selected = True Then
                con.Open()
                cmd.Parameters.AddWithValue("@interestid", Item.Value)
                cmd.ExecuteNonQuery() 'for updating database'
                lblmessage.Text = "Successfull"
                cmd.Parameters.Clear()
            Else
                lblmessage.Text = "Error"
            End If
            con.Close()
        Next
    End Sub

Here’s the aspx page markup:

 <asp:CheckBoxList ID="chkboxinterest" runat="server" RepeatColumns="3" 
            Width="650px">
       <asp:ListItem class="chkbox" runat="server" Text="Aerobics" Value="1" />
       <asp:ListItem class="chkbox" runat="server" Text="Antiques & Collectibles" Value="2" />
       <asp:ListItem class="chkbox" runat="server" Text="Arts & Crafts" Value="3" />
       <asp:ListItem class="chkbox" runat="server" Text="Astronomy" Value="4" />
       <asp:ListItem class="chkbox" runat="server" Text="Auto Racing" Value="5" />
    </asp:CheckBoxList>
  • 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-05-23T05:20:25+00:00Added an answer on May 23, 2026 at 5:20 am

    First, there is no need to add parameters to your SQL Command so often.

    cmd.Parameters.AddWithValue("@interestid", Item.Value) 
    

    You need to change that.

    Before your loop, add the parameter (without value) to the SqlCommand. However, declare it as type SQLDbType.int.

    cmd.Parameters.Add("@interestid", SQLDBType.Int)
    

    Then, in your loop, you just need to change the value of the SQL Command.

    cmd.Parameters("@interestid").Value = Item.Value
    

    Remove cmd.Parameters.Clear()

    Second, Remove con.Open() and con.Close() from your loop.

    You only need to open the connection before the loop, and close it after the loop.

    Third, perform some input validation on Item.Value

    Is it really in the range that you think it is? Either use a RangeValidator in your markup, or perform some custom logic in the code-behind. At the very least, do this: CInt(Item.Value)

    Fourth, your Alter Procedure statement is missing the required AS keyword

    http://msdn.microsoft.com/en-us/library/ms189762.aspx

    Alter MyProc (@param int) **AS** Select * from Products
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to insert data into MS SQL server 2008 using Ole DB.
I'm trying to insert values into a SQL database from within Java. This works
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
Am trying to insert XML into XML Column.. getting following error: . Msg 6819,
Trying to insert values with Unicode Chars into a MySQL-database using Delphi 2010 and
I'm trying to insert into XML column (SQL SERVER 2008 R2), but the server's
I'm trying to insert multiple rows using SqlCommand from C# to SQL Server. I'm
im trying to insert an array values into the file using foreach.. and if
I am trying to INSERT INTO a table using the input from another table.
I'm trying to insert a comment character into a string something similar to this:

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.