I got error “The DELETE statement conflicted with the REFERENCE constraint”

The error means that you have data in other tables that references the data you are trying to delete. You would need to either drop and recreate the constraints or delete the data that the Foreign Key references. Suppose you have the following tables dbo.Students ( StudentId StudentName StudentTypeId ) dbo.StudentTypes ( StudentTypeId StudentType ) … Read more

Truncate string on whole words in .NET C#

Try the following. It is pretty rudimentary. Just finds the first space starting at the desired length. public static string TruncateAtWord(this string value, int length) { if (value == null || value.Length < length || value.IndexOf(” “, length) == -1) return value; return value.Substring(0, value.IndexOf(” “, length)); }

Pros & Cons of TRUNCATE vs DELETE FROM

TRUNCATE doesn’t generate any rollback data, which makes it lightning fast. It just deallocates the data pages used by the table. However, if you are in a transaction and want the ability to “undo” this delete, you need to use DELETE FROM, which gives the ability to rollback. EDIT: Note that the above is incorrect … Read more

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