예제 #1
0
        // handles any data type and nulls
        public static void UpdateColumnByKey(string table, string dataColumn,
                                             object dataValue, string keyColumn, object keyValue)
        {
            var sql =
                $"UPDATE {EncloseName(table)} SET {EncloseName(dataColumn)}=@p1" +
                $" WHERE {EncloseName(keyColumn)}=@p2";

            using (var cn = Current.Connection)
            {
                cn.Open();
                var cmd = Current.Command(sql, cn);
                cmd.CommandTimeout = 3600;

                Current.AddCommandParameter(cmd, "p1", dataValue);
                Current.AddCommandParameter(cmd, "p2", keyValue);

                cmd.ExecuteNonQuery();
            }
        }