Solved

SQLite:  Unable to cast from source type to destination type

Posted on 2011-02-15
2
1,557 Views
Last Modified: 2012-05-11
What's wrong with these statements?  I'm getting an error on the statement indicated:

Cannot cast from source type to destination type.
string searchCmd = "SELECT COUNT(*) FROM SiteData WHERE SITE_ID = '" +  txtSiteID.Text + "'";       
c.CommandText = searchCmd;
if(SQLite.conn.State == ConnectionState.Closed)
    SQLite.conn.Open ();

int siteCount = (int)c.ExecuteScalar();  //  <-------  error occurs here

Open in new window

0
Comment
Question by:rmmarsh
2 Comments
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 34901439
try

int siteCount  = Integer.Parse(c.ExecuteScalar().ToString);
0
 

Author Closing Comment

by:rmmarsh
ID: 34901630
Thank you...
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 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