Wrox Programmer Forums
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 28th, 2006, 03:14 PM
Authorized User
Join Date: Sep 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loops

I'm running a program were the person at the start of the day will check each person's name who is in the office for that day. That person name will be added to a table, to be included in a phone rotation. I'm passing that name through a parameter called strName to run a stored procedure. The program works if I check one person's name at a time and press submit. How Can I check everyone's name at one time and press submit, and it's adds everyone's name to that table? I know I need some kind of a loop.

This is my code:
strconnection = New SqlConnection(Application("strConnection"))
        strName = chkListbox.SelectedItem.Value
        Dim saveSpecialist As SqlCommand = New SqlCommand ("spSaveCS", strconnection)
        saveSpecialist.CommandType = CommandType.StoredProcedure
        With saveSpecialist.Parameters
            .Add("@Name", strName)
        End With
Alexander Nelson
Old September 28th, 2006, 03:27 PM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Ya you need something like this:
Dim item as new listitem

for each item in chkListBox.Items
   if item.selected then
     strName = item.value
     //sql code
   end if

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
Old September 28th, 2006, 03:48 PM
Authorized User
Join Date: Sep 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks dparsons you are a genius!!!

Alexander Nelson

Similar Threads
Thread Thread Starter Forum Replies Last Post
break for-each loops, or limit amount of loops warhero XSLT 2 July 4th, 2007 02:18 AM
Two Loops iloveoatmeal Classic ASP Basics 5 September 26th, 2005 09:59 AM
While loops and For loops in XSLT spencer.clark XSLT 1 August 5th, 2005 09:50 AM
loops Hudson40 Access VBA 1 February 4th, 2005 12:58 PM
Loops Hudson40 Excel VBA 2 January 20th, 2005 07:40 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.