Solved

SQLite:  Unable to cast from source type to destination type

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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.​
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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