Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
create table emp(id int auto_increment,ename varcahr(50),sl decimal(10,2),DOB datetime)
CREATE TABLE `test`.`emp` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`salary` DECIMAL(10,2) NOT NULL,
`DateOfBirth` DATETIME NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
id name salary DateOfBirth
1 A 1000 1986-10-10
2 B 2000 1985-02-08
3 C 3000 1990-01-11
4 D 4000 1980-03-03


1)in asp.net when page loading dispaly all the values in a gridview
2)when i gave a from date form asp.net 1986-10-10 display values DateOfBirth >= FROMDATE
3)when i give to date 1985-01-01 dsiplay values DateOfBirth<= TODATE
4)if give both dates DateOfBirth >= FROMDATE and DateOfBirth<= TODATE display with in these values
5)if give empty text dates dispaly the total table with dates
plz give a stored procedure for this
i am write this procedure but null values not taken it
DELIMITER $$
create procedure getClient(in FROMDATE date,in TODATE date)
begin
SELECT id,name,salary,dateofjoin
FROM emp
where (DateOfBirth <= FROMDATE or FROMDATE is null )/* but here null values not taken like sql*/
AND (DateOfBirth>= TODATE or FROMDATE is null);

end $$
DELIMITER ;
Posted
Updated 7-Nov-11 19:17pm
v3
Comments
thirupathi2011 10-Nov-11 7:24am    
thanks for u r suggestion......
if i send like this i got error
cmd.Parameters.AddWithValue("clientid",DBNull.Value);

When calling stored procedures and 'Use Procedure Bodies' is false, all parameters must have their type explicitly set.

1 solution

Not quite clear, But you may use DBNull.Value to pass null values while calling your Stored Procedure from .Net.
 
Share this answer
 

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