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 3241206
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:10:20+00:00 2026-05-17T18:10:20+00:00

I have a form that allows users to insert items in a database. A

  • 0

I have a form that allows users to insert “items” in a database. A field asks how many items they want to insert. Identical data (apart from their ID) is inserted in the database the number of times they chose. I’ve found different ways to insert multiple items but not when this is dynamically done. I’m using .net 3.5 and SQLServer 2005. Do I have to use a For…Next statement or is there any other way? Thanks

UPDATE: My simplified insert code is as follows:

    Dim sqlCmd1 As String

    sqlCmd1 = "INSERT INTO Table_Items (ItemType, ItemDescription, ContactName, ContactEmail) VALUES (@ItemType, @ItemDescription, @ContactName, @ContactEmail);"

    'Dim ID As Integer
    Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()
    Dim conn As SqlConnection = New SqlConnection(connectionString)
    Dim Cmd1 As SqlCommand = New SqlCommand(sqlCmd1, conn)

    With Cmd1.Parameters
        .Add(New SqlParameter("@ItemType", Textbox1.Text))
        .Add(New SqlParameter("@ItemDescription", Textbox2.Text))
        .Add(New SqlParameter("@ContactName", Textbox3.Text))
        .Add(New SqlParameter("@ContactEmail", Textbox4.Text))

    End With

    Try
        conn.Open()
        ID = Cmd1.ExecuteScalar()
        Server.Transfer("confirmation.aspx")
        conn.Close()
    Catch ex As SqlException
        lblError.Text = ex.Message()
    End Try
  • 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-17T18:10:20+00:00Added an answer on May 17, 2026 at 6:10 pm

    The simplest way to go with your style just add call to Cmd1.ExecuteScalar() in cycle

    For i As Integer = 1 To Counter Cmd1.ExecuteScalar() Next

    But be aware this is certainly not right way for general usage. While you keep it small, there are no so much overhead, else better go @anivas way.

    Also check ASP.NET Data Access Tutorials and I would recommend to switch to LINQToSql if it’s possible. It will save you a lot of time. Check Using LINQ to SQL Series, LINQ via C# and Using LINQ to SQL in Visual Basic

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

Sidebar

Related Questions

I have a form that is trying to insert some data into an SQL
We have a form that allows a user to filter a list with by
I have a product registration form that allows the user to add additional product
Let say I have a website that allows users to send articles on that
I have a wordpress blog. I made a custom page-template that allows users to
I have form that displays several keywords (standard set of choice lists that changes
I have a form that contains a GridView control which is databound to an
I have a form that I would like to style. specifcally I would like
I have a form that searches all rows in a single table (TServices) that
I have a form that is sending in sizes of things, and I need

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.