SQLite Forum

SQLiteConnection.Execute is not affecting
Login

SQLiteConnection.Execute is not affecting

(1.1) By bllas (Lakmal) on 2021-08-29 12:52:28 edited from 1.0

If have below code. It doesn't give any error and execute method return 1 as expected. But it doesn't impact the DB. What am I missing. I'm using c# code

try {

            using (SQLiteConnection clientconnectiion = new SQLiteConnection(connstring))

            {
                var parameters = new { ConfigParameter = ConfigParameter, ConfigValue = ConfigValue };
                var sql = "Update ApplicationConfiguaration " +
                          " set  ConfigValue = '@ConfigValue' " +
                            " where ConfigParameter = @ConfigParameter";

                var res = clientconnectiion.Execute(sql, parameters);

            }

        }


Further, please note that select statement returns the data without any issue.
Bllas

(2) By Larry Brasfield (larrybr) on 2021-08-29 13:14:39 in reply to 1.1 [link]

> <code>var parameters = new { ConfigParameter = ConfigParameter, ConfigValue = ConfigValue };
</code>

Perhaps, in the interest of clarity, you could initialize with literals to avoid extraneous questions such as "What are the values of ...?"

> var sql = ... " set  ConfigValue = '@ConfigValue' " ...

That's almost certainly not what you intend. Parameter substitution does not occur inside of SQL string literals.

> But it doesn't impact the DB.

I suppose that by "impact" you mean "alter". I have no idea whether this is because the DB already contains the values you set in this code or something else is going on.