Solved

Cannot Implicitly convert type error

Posted on 2010-09-14
2
388 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

21 Experts available now in Live!

Get 1:1 Help Now