How do I translate a List into a SqlParameter for a Sql In statement? [duplicate]

You could try something like this: string sql = “SELECT dscr FROM system_settings WHERE setting IN ({0})”; string[] paramArray = settingList.Select((x, i) => “@settings” + i).ToArray(); cmd.CommandText = string.Format(sql, string.Join(“,”, paramArray)); for (int i = 0; i < settingList.Count; ++i) { cmd.Parameters.Add(new SqlParameter(“@settings” + i, settingList[i])); }

Zero SQL deadlock by design – any coding patterns?

Writing deadlock-proof code is really hard. Even when you access the tables in the same order you may still get deadlocks [1]. I wrote a post on my blog that elaborates through some approaches that will help you avoid and resolve deadlock situations. If you want to ensure two statements/transactions will never deadlock you may … Read more

Modify materialized view query

No, you cannot alter the query of a materialized view without dropping it. The CREATE MATERIALIZED VIEW syntax does not support that feature. The ALTER MATERIALIZED VIEW is used to modify an existing materialized view in one or more of the following ways: To change its storage characteristics To change its refresh method, mode, or … Read more

Declaring and using MySQL varchar variables

This works fine for me using MySQL 5.1.35: DELIMITER $$ DROP PROCEDURE IF EXISTS `example`.`test` $$ CREATE PROCEDURE `example`.`test` () BEGIN DECLARE FOO varchar(7); DECLARE oldFOO varchar(7); SET FOO = ‘138’; SET oldFOO = CONCAT(‘0’, FOO); update mypermits set person = FOO where person = oldFOO; END $$ DELIMITER ; Table: DROP TABLE IF EXISTS … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)