Solved

Cannot Implicitly convert type error

Posted on 2010-09-14
2
386 Views
Last Modified: 2012-05-10
I am getting the following error when I try to use Where clause in a LINQ statement:

Error      1      Cannot implicitly convert type 'System.DateTime' to 'bool'

I am trying to get back an ID from a table that has a matching date from combobox value.  Table I am getting the information from consists of a field call PK_StatementDateID (bigint type) and InvoiceDate (datetime type).  What am I doing wrong here?

np
Statements_ARDataContext db = new Statements_ARDataContext();



            var Id = from d in db.GetTable<StatementDate>()

                     where d.InvoiceDate = Convert.ToDateTime(comboBox1.SelectedValue)

                     select d;

Open in new window

0
Comment
Question by:countyprob
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 33677296
Replace:
where d.InvoiceDate = Convert.ToDateTime(comboBox1.SelectedValue
with:
where d.InvoiceDate == Convert.ToDateTime(comboBox1.SelectedValue

Notice the == comparison operator
0
 
LVL 1

Author Closing Comment

by:countyprob
ID: 33677410
Doh!!! I can't believe I missed that one.  Thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now