Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I programatically set the where parameter of a LINQ DataSource control for a datetime Type?

Posted on 2011-09-26
4
Medium Priority
?
1,337 Views
Last Modified: 2012-05-12
Hi

How can I programatically set the where parameter of a LINQ DataSource control for a datetime Type?

Have tried thses but no luck

LinqDataSource1.Where = "SomeDate = 11/11/2001";

LinqDataSource1.Where = "SomeDate = @SomeDate";
LinqDataSource1.WhereParameters.Add("SomeDate", DbType.DateTime, "11/11/2001");

LinqDataSource1.WhereParameters["SomeDate"].DefaultValue = "11/11/2001";
0
Comment
Question by:johngrant_ks
  • 2
4 Comments
 
LVL 12

Expert Comment

by:jagssidurala
ID: 36702294
Try this

Dim objFilterdata = From objSource in LinqDataSource1 Where objSource.SomeDate = "11/11/2001"

this is in vb.net


0
 
LVL 13

Expert Comment

by:jonnidip
ID: 36707567
Is this what you mean?
... SomeDate = new DateTime(2011,11,11)...

Regards.
0
 

Accepted Solution

by:
johngrant_ks earned 0 total points
ID: 36713862
Thanks For the help

This i s what eventually fixed the problem it was alot to do with the format of the date yyyy-MM-dd



 
StringBuilder whereClause = new StringBuilder();

 DateTime datDatePurchase = Convert.ToDateTime(DateControl8.wctxtDateControl.Text.HtmlEncode().ToString());
            whereClause.Append("DatePurchased >= DateTime.Parse(\"" + datDatePurchase.ToString("yyyy-MM-dd") + "\")");

LinqDataSource1.Where = whereClause.ToString();

Open in new window

0
 

Author Closing Comment

by:johngrant_ks
ID: 36899009
Answered my own question
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question