Regarding Count through asp.net..

Posted by Gopal_nivas under Sql Server on 9/13/2010 | Points: 10 | Views : 1130 | Status : [Member] | Replies : 1
hi..

i was created a table named "contacts"..

in tat contact table i have a column called "createdby"

then if a admin can create a new contact info. those details will be inserted and the created by column have the value user name or id..

in that the login user can create new user i.e) user regsitration to login..

the registerd user details are inserted into another table..

and also i have maintaining another table called "user_reg"

in tat table i have 3 columns namely "id","adminid","userid"

here i want to "count" the contact info. according to "createdby" column value..

that is..

contact table:

id name Addre createdby
1 raj ss admin
2 ram ww a
3 john rr b

user_reg table
id adminid userid
1 0 1
2 0 2


user_info
id name pw
0 admin admin
1 a a
2 b d




the admin and its users can able to insert contact info upto 100 only..

so i am taking the count of admin and those users are created by admin tat count also i am going to take..

so if tot1l=100 then nobody (admin and its users cant able to insert contacts) and simultaneously for other users..

so how to achieve this..

need ur suggestions..


regards
gopal.s




Responses

Posted by: T.saravanan on: 9/13/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Gopal,

Using Procedure you can achieve your output easily.

In Your Procedure,
Here Pass @sAdminId --> your Login User Id

Declare @nCount int
Set @nCount =(select count(id) from user_reg where createdby =@sAdminId)
If(@nCount <100)
Begin
Insert Statement // Its for your insert statement
End
else
return false // Its for your message
End


If any doubt ask to me.

Cheers :)

Thanks,
T.Saravanan

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response