Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 08, 2012 08:39 AM by joshuait
Sep 07, 2012 07:06 AM|LINK
My Client is getting the following error randomly. I even not able to find out the reason.
Exception type : InvalidCastException
Exception message: Unable to cast object of type 'System.Boolean' to type 'System.String'.
Stack trace: at BindTypes.GetAgreement(String userA)
at billenroll_Wizard.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
According to my understanding based on stack trace, this error occurs on the following function.
public class BindTypes
public static string GetAgreement(string A)
string tab = "";
if (A == "biller")
tab = "b_agreement";
tab = "r_agreement";
db = new DBdefault();
string sql = "SELECT ["+tab+"] FROM [messages] WHERE [id] = '0'";
Sep 07, 2012 07:12 AM|LINK
Sep 07, 2012 07:20 AM|LINK
I need to return string value and my query will return string value. Here there is no way for Boolean values.
Sep 07, 2012 07:49 AM|LINK
Sep 07, 2012 08:23 AM|LINK
Sorry, it was my mistake, you have to do like this.
return Convert.ToBoolean(db.GetScalar(sql)) ? "true" : "false"
Sep 07, 2012 08:29 AM|LINK
I don't know where it is going wrong. My Query will return string values like this 'I am here'. Hence I am returning the same string. In that function i am NOT doing any work with Boolean.
The actual value, the query returns is "According to agreement...' like that it will go on..
Sep 07, 2012 08:36 AM|LINK
My Client is getting the following error randomly
you have to check your above method db.GetScalar(sql). and also try to figure out in what case your application is throwing error. you have to check with those record on which you are getting error.
Sep 07, 2012 08:37 AM|LINK
IF EXISTS (SELECT * FROM .....)
Sep 07, 2012 08:40 AM|LINK
That table is having only one record. By based on user we will show the values of different column. And I don't know in what case it is throwing the error. If i know i would have fixed that.