Solved

SQLite:  Unable to cast from source type to destination type

Posted on 2011-02-15
2
1,544 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

22 Experts available now in Live!

Get 1:1 Help Now