Click here to Skip to main content
14,303,730 members
Rate this:
Please Sign up or sign in to 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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.

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 ☺
   
v2

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100