CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

YesSoftware Forums -> CodeCharge Studio -> .NET

 Error in loop

Print topic Send  topic

Author Message

Posts: 60
Posted: 08/23/2004, 8:44 AM

I created a loop that goes through a listbox, and grabs the selected value if its selected, stores it in a parameter, then runs a stored procedure in sql, then does the same thing for the next selected item in the listbox. However I get the error "The SqlParameter Collection only accepts non-null SqlParameter type objects, not String object" every time. It does however insert the first selected record, but seems to error out when it loops again. I can't figure this out for the life of me. Here's my vb code:

   Dim sTeamLeaderID, sCounselorID As String  
   Dim sqlConn As New SqlClient.SqlConnection("server=(local); uid=sa; pwd=;initial catalog=IFPAWEB")  
   Dim sqlSPteam As New SqlClient.SqlCommand("sp_teamleadercounselor", sqlconn)  
   Dim i As Integer  
			For i = 0 To CounselorsCounselors.Items.Count - 1  
                If CounselorsCounselors.Items(i).Selected Then  
					sTeamLeaderID = CounselorsTeamLeaderName.Value  
                    sCounselorID = CounselorsCounselors.Items(i).Value.ToString  
                    With sqlSPteam  
                        .Connection = sqlConn  
                        .CommandType = CommandType.StoredProcedure  
                        .Parameters.Add("@counselorid", convert.ToInt32(sCounselorid))  
						.Parameters.Add("@teamleaderid", convert.ToInt32(steamleaderID))   
                    End With  
                 End If  
            Next i  
        End Try  

and here is my stored procedure:

CREATE proc sp_teamleadercounselor  
@counselorid int,  
@teamleaderid  int  
declare @date1 datetime  
set @date1=getdate()  
--delete teamleadercounselor where teamleaderid=@teamleaderid  
insert into teamleadercounselor (teamleaderid,counselorid,modify_date)  
values (@teamleaderid,@counselorid,@date1)  

View profile  Send private message

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

Web Database

Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.