CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> .NET

 Error in loop

Print topic Send  topic

Author Message
drpcken

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  
  
     Try  
        sqlConn.Open()  
		Finally  
			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))   
					    .ExecuteNonQuery()  
						.Parameters.Remove("@counselorID")  
						.Parameters.remove("@teamleaderid")  
											     
                    End With  
						  
                 End If  
				 						      
            Next i  
		  SqlConn.Close()  
        End Try  


and here is my stored procedure:


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


Thanks!!!
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 http://support.yessoftware.com.

Web Database

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

Home   |    Search   |    Members   |    Register   |    Login


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