Click here to Skip to main content
16,004,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Please help me, How to delete multiple records in database with xml as input parameter in c#.

I just need the stored procedure in sql server 2005.

Please help me, its very urgent.


Regards
Nagaraj.J
Posted
Comments
syed shanu 14-Apr-14 2:19am    
From your c# program read all xml data using loop and inside loop call the SP and pass the xml deletetion parameter to delete Delete from your table_name where conditon=@paramaeter
Member 10454499 14-Apr-14 3:05am    
Hello Syed, If i call sp inside the loop it will call sp for every id, i think its a big process and takes lot of time, Instead of that i think xml parameter is best

1 solution

See
Collect you data in a string lit
string IDs="1,5,7"

Pass this IDs to your storeprocedure as a parameter

And write a query like
Delete from your table_name where ID in (@IDs)


See a link which is discussed on this matter

http://forums.asp.net/t/1859005.aspx?Delete+multiple+records+using+SQL+Delete+Query[^]
 
Share this answer
 
v3
Comments
Member 10454499 14-Apr-14 3:02am    
Thank you Sankarsan, i tried with the tip you given, but am getting error converting datatype varchar to bigint, i tired convert that string in bigint in stored procedure but i takes only first value. Please help how to solve this.
[no name] 14-Apr-14 3:09am    
See I have given a link in above answer see the topic which will help you
Member 10454499 14-Apr-14 3:24am    
Thank you very much sir, It solved my problem.
[no name] 14-Apr-14 3:25am    
welcome :)

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