Date as a Parameter for SQL Server query using ASP.NET

I want to insert some data along with the date into SQL Server 2000 using ASP.NET. I have used "DateTime.Now" to get the current local system time using C sharp and then inserted that value in SQL Server.

Now my task is to select some idNumers from the SQL Server . The query looks somewhat like

  select idNumber from  users where UserID=? and Date>=?

I select the parameters "UserID" and "Date" depending on the session userId and date from local system using "DatTime.Now". I used DataSet for this task.

I am getting no rows selected even though there are rows which can satisfy the above query.

How can I add Date as a paramter. Shall I have to do any explicit casting for this.

Plz help me to solve this problem
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rename the "date" column to be something like "userdate" or something aside from "date" which is a reserved word.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You may want to change the Date column name as said by nan1217 or if not then trying putting Date in square brackets so the query defines the word Date as a field name.

I have also found that the format of the date can make a difference on whether a < or > actually works.  I recommend using the format YYYY/MM/DD so as not to confuse matters on whether it is Euro or US date style.
like already mentioned by dij8, i encounterd big problems with dateformats, too.

for me the following date-format has been the solution - but this format does not work with all configurations, too. if you use it, take care of the "/" and ":" because c# converts these signs to the format your culture-settings fit.

"yyyy/MM/dd HH:mm:ss"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.