私のウェブサービスコード
[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 > 0)
return "Ok";
else
return "not Ok";
}
}
例外が発生し、これがコールスタックです:
System.Data.SqlClient.SqlException: Incorrect syntax near '555'.
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
これを修正する方法は?