Click here to Skip to main content
15,899,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have database table: tblPerson as,

id name     mobile_no   sentcount
1   Ram     98********   4
2   Shyam   98********   4
3   Hari    98********   5
4   Raj     98********   3


now i want send sms to those two person who have sentcount less than the maximum sentcount.(here maxm sentcount=5);
i used sql storeproc as:

SQL
create proc sp_getMobileNo
@sentcount int
as
Select (select top 2 mobile_no + ',' as 'data()' from tblPerson  where sentcount<@sentcount ORDER BY NEWID()for xml path('')) as MobileNo


it gives the result as:
MobileNo
----------------------
98********, 98********
-----------------------


I have used linq to get the data in the ASP.Net application C# as language and succeded to send text message to two selected numbers;i used linq as:
C#
linqDataContext db= new linqDataContext();
var query=db.sp_getMobileNo(5);
string mobileNum=query.MobileNo;


but i want to update or increase the sentcount of those two whom sms has been sent.
So please suggest me what to do? Is the way of retreving the mobile in concated form as xml path the correct way to retreive the mobile number?
Please help!!!
Posted
Updated 24-May-13 10:48am
v5
Comments
Jameel VM 24-May-13 10:17am    
where is your update code? did you try anything for updating? where you are actually stuck?

1 solution

Finally i have found the solution. First of all the option of getting mobile no. as XML path was bad option in my case. I simply selected the mobile_no along with person id,copied it to datatable and using foreach loop i put both id and mobile in array. i concatenated the mobile no. along with comma to get mobile_no in the form 98**********,98*********,. and so updated the count of the id inside the same loop.
 
Share this answer
 
Comments
CHill60 29-May-13 11:19am    
I'm not convinced that you needed to put anything into an array if you already had it in a DataTable. You might be able to simplify your code

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