Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear expert,

please provide a sample loop and codes that is in ASP.NET, C#.

or better a reference site that performs the following routine :


The control of the loop is C#, asp,net

but the insert of the generated data is done in the stored procedure



If there are 10 records to be worked .

The control of the loop is from the asp,net program.

After each process the output is sent to a stored procedure.
Posted
Updated 24-Nov-14 17:15pm
v2
Comments
virang_21 24-Nov-14 23:24pm    
where is your code ?

You can pass the data as a table..
for that you can use UDTs (User Defined Table Types)
this is the code for creating a UDT

SQL
CREATE TYPE [dbo].[ttAddressType] AS TABLE(
    [addressTypeID] [int] NULL,
    [addressType] [nvarchar](500) NOT NULL
)
GO


You can use this in your stored procedure like
SQL
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      Jineesh
-- Create date: 29-11-2012
-- Description:	
-- =============================================
ALTER PROCEDURE [dbo].[spAddressType]
(@addressType ttAddressType READONLY)

AS
BEGIN
	SET NOCOUNT ON;
	SET XACT_ABORT ON;
	
	BEGIN TRY
		BEGIN TRAN

--code for inserting in to table

              COMMIT TRAN
       END TRY
END
 
Share this answer
 
Comments
Member 10744248 25-Nov-14 4:27am    
where is the table to be created in c# or in the stored procedure
Jineesh TR 25-Nov-14 5:36am    
in c# you create a data table and pass it to the stored procedure.
Hi,

Please provide some code you have tried..

anyway, you can use foreach or for loop in your C# code. and you can pass all the rows to a stored procedure, from there you can move it to a temporary table.

Please check
 
Share this answer
 
Comments
Member 10744248 25-Nov-14 2:55am    
how do you hold the rows before passing it to the stored procedure

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900