Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hello every one

i am trying to develop a library management system using sql and c#

in LBMS a person is allowed to take only 4 books and i want to put a condition in my LENdING _DETAILS TABLE such that no value above 4 is allowed in NUM_OF_books_TANKEN column. how could i do that can u guys help with the your suggestions.

thanks in advance.
Posted
Comments
Amir Mahfoozi 22-Dec-13 6:45am    
use Constraints.

1 solution

simple make a table,records save of Book keeping.view of Table id,name,status,booksname. when this table entry before we check count of Id with the help of where condition status=true.

SQL
select count(*) from TableName where id=@id and 
insert into TableName values(id,BooksName) where status=true
create proc testing
(
@id int=0,
@books varchar(max)=null,
@nameofStudent varchar(max)=null,
@bookid varchar(max)=null


)

as 
declare @tempCount int;
select @tempCount=COUNT(status) from tableName where ID=@id
if(@tempCount<4)
begin
insert into Tablename values(@id,@bookid,@nameofStudent,@books)



end
else

begin
print'this student allready have four books'
end


return


for any query hit to reply..
happy to Help ☺
 
Share this answer
 
v2

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