Solved

Cannot Implicitly convert type error

Posted on 2010-09-14
2
395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

696 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