I wrote a piece of simple code that I dont to find what the problem.
the code is:
var sortSecurities="SELECT * FROM securities";
int total=0;
var value="";
foreach(var row in db.Query(sortSecurities))
{
value=row.lastGate;
total=Convert.ToInt32(value)*100;// here the problem with compilation..
db.Execute("INSERT INTO holding(IDgrossPortfolio,IDSecurity,totalHolding,units,buyGate) "+"VALUES (@0,@1,@2,@3,@4)",row.category,row.number,total,"100",row.lastGate);
}
what the problem with the convert?
the error is:
Exception Details: System.FormatException: Input string was not in a correct format.
valuedoes not hold a value that can be converted to Int32. If you could do some debugging and see what the value of it is fromrow.lastGate, you might see what the problem is.Also, not sure what is returned by
db.Query(sortSecurities)(or really what kind of objectrow.lastGateis), but you can also try to changevalue=row.lastGate;tovalue=row.lastGate.ToString();