Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I'm working on an app and the specific form I'm working on
is connecting to SQL, also yes using stored procedures ofcourse.

But I have been having a problem with the displaying.
I only want it to display the items for the certain month.
It works with datagridview and datetime picker.

So basicly when I choose a month it must check in SQL to be the same month
and diplay that months info.

Not sure if the problem is in C# or stored proc.

Please can anyone help me with this??
Posted
Comments
Toniyo Jackson 21-Jul-11 2:58am    
Can you post your stored procedure?
shefeekcm 21-Jul-11 2:58am    
provide your code and procedure.
shefeekcm 21-Jul-11 3:01am    
your field type is datetime in databse,you need to send full date,otherwise it may cause problems.

My preference would be to filter at the stored procedure level, why return all of your rows unless the user choses to display all.

You would simply pass the month number to the stored procedure as a param, and add the month filter to your WHERE clause... I don't know the sql syntax to pick the month value out of a date field, but I know there is one.
 
Share this answer
 
Select month(MyDate) from Table1 gives you only the month. Try with this sort of filtering.
 
Share this answer
 
v2
fcronin is right, you should filter in your stored procedure:
SQL
... WHERE (DATEPART(month, dateField) = @monthParameter)
 
Share this answer
 
fcronin is right. you should filter in ur sp
 
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