View Single Post
  #1 (permalink)  
Old February 22nd, 2007, 06:15 PM
hertendreef hertendreef is offline
Friend of Wrox
 
Join Date: Apr 2006
Location: , , .
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to pass value to stored procedure?

Hi,

i need to insert a record 1 or more times, depending of a variable in code-behind:
dim amount as integer
amount= value (e.g. 3)

My problem is: how to pass that variable to the stored procedure?
I tried with this but nothing happens:

comd.Parameters.Add("@amount", SqlDbType.NVarChar, 10).Value = amount_of_details

Maybe is my stored procedure wrong?
Thanks
H.

Here is it:
----------

ALTER PROCEDURE dbo.insert_table
 (
@field1 nvarchar(10)
,...
)
AS
Declare @iLoopNumber int
Declare @amount int
BEGIN TRAN

SET @iLoopNumber = 1

SET @amountr


While (@iLoopNumber <= @amount)

BEGIN

INSERT INTO table(field1,...)

VALUES (....))

 SET @iLoopNumber = @iLoopNumber +1

End


COMMIT TRAN



Reply With Quote