Solved

Cannot Implicitly convert type error

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to reference objects of the calling class without passing them as parameters 29 176
designing in object programming 12 78
Windows Media Player 2 26
InputLanguage 1 26
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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