TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prasad Vempati
NA
15
0
Data retrieving from SQL Server with C#
Mar 14 2010 4:21 AM
I am trying to retrieve the data between two dates using C# with SQL Server database. I am passing dates entered in two text boxes to the sql statement as show below
"
SELECT SUM(CONVERT(DECIMAL(6,2),howmuchspent)) AS totalexpenses FROM MONTHLYEXPENSES WHERE expensesdate BETWEEN ' "
+ fromdate.Text +
" ' AND '"
+ todate.Text +
"' "
;
With the statement above I am getting data that from the required date range and also data that is out of date range too.
When I tested the statement in SQL Server query screen by giving dates as follows
SELECT SUM(CONVERT(DECIMAL(6,2),howmuchspent)) AS totalexpenses FROM MONTHLYEXPENSES WHERE expensesdate BETWEEN ' 03/01/2010
' AND '03/13/2010
'
I get data exactly between those dates.
What was the wrong I was doing in retrieving data programatically?
Any help is appreciated. Thank you
Reply
Answers (
6
)
Environment Variables Return Null
Datagridview delete