?
Solved

SQLite:  Unable to cast from source type to destination type

Posted on 2011-02-15
2
Medium Priority
?
1,571 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
[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 59

Accepted Solution

by:
HainKurt earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

719 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