Solved

SQLite:  Unable to cast from source type to destination type

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

Accepted Solution

by:
Huseyin KAHRAMAN 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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 …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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