Note that there are some explanatory texts on larger screens.

plurals
  1. POError with decimal
    primarykey
    data
    text
    <p>My webservice code</p> <pre><code>[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { SqlConnection con = new SqlConnection( "Server=NOVA-PC;database=totev006;User ID=***;Password =***;"); public Service () { } [WebMethod(Description = "Update return in Bet")] public string setReturn(int EventID) { string sql = ""; decimal dcm = (decimal)100.5 + (decimal)45.055; int BetTypeWinID = 1; int BettorID = 1; int ins = 0; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; sql = "update bet"; sql += " set [return] = " + dcm; sql += " where event_id = " + EventID; sql += " and bet_type_id = " + BetTypeWinID; sql += " and bettor_id = " + BettorID; cmd.CommandText = sql; ins += cmd.ExecuteNonQuery(); con.Close(); if (ins &gt; 0) return "Ok"; else return "not Ok"; } } </code></pre> <p>I get exception and this is the callstack:</p> <pre><code>System.Data.SqlClient.SqlException: Incorrect syntax near &amp;#39;555&amp;#39;. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Service.setReturn(Int32 EventID) in e:\Learning\Webservice\demo\webservice\App_Code\Service.cs:line 49 </code></pre> <p>How to fix this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload