Click here to Skip to main content
14,456,102 members
Rate this:
Please Sign up or sign in to vote.
See more:
It is my coding:

WebService.asmx.cs
[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public void UpdateGoogleDate(String jsonOfDataMimoGoogleDate)
        {
            DbAccessConnection conn = getActiveConnection();

            if (conn == null)
                return;

            try
            {
                beginTransaction(conn);

                AccountGoogle google = new AccountGoogle(conn);
                User users = Tools.convertJsonIncludeDerivedTypes<User>(jsonOfDataMimoGoogleDate);

                google.updatedate(users);


                commitTransaction(conn);
                Responder.writeResponse(true, "Success Update Date Google");
            }
            catch(Exception ex)
            {
                rollbackTransaction(conn);
                Responder.writeResponse(false, ex.Message, ex.StackTrace);
            }
        }


AccountGoogle.cs
public void updatedate(User dtGoogle)
       {
           String sql = $"UPDATE google SET datetime = ('{dtGoogle.Datetime}') WHERE id = ('{dtGoogle.Id}')";
           Connection.executeSql(sql);
       }


It is success execute method updatedate with message:
{"isSuccess":true,"resultMessage":"Success Update Date Google","data":null}


Could you help me how to fix it ?

What I have tried:

But i don't know show my field status it is write online in table google and it is didn't update it is write offline

My field in table google is id,email,name,datetime,status
Posted
Comments
Richard Deeming 18-Feb-20 14:28pm
   
There's a very good chance that your code could be vulnerable to SQL Injection[^].

Unless the executeSql method is declared as taking a FormattableString[^], and is specifically written to convert the format arguments into proper parameters, then you have a serious problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100