VS2012 and VS2013 Add a lightweight database LocalDB. With this, developers do not have to install a large SQL server to conveniently test and run small projects. Since it is a lightweight database, it discards a huge body and is also limited in functionality. One of them is its default sorting rules, which are used by default, chinese data added from the front-end of the website displays garbled characters or question marks in the database. This problem has plagued me for several days and finally found a solution through various searches, hope to help you with the same confusion!
1. Right-click the database instance, create a query, and change the database to single-user mode.
Alter database [database name or full path] set single_user with rollback immediate;
Go
2. Modify the sorting rule (Chinese here -- Pinyin -- case-insensitive)
Alter database [database name or full path] collate Chinese_PRC_CI_AS;
Go
3. Reset to multi-user mode
Alter database [database name or full path] set multi_user;
The name of a sorting rule consists of two parts. The first half is the character set supported by this sorting rule.
For example:
Chinese_PRC_CS_AI_WS
First half: the UNICODE character set. The Chinese_PRC _ pointer sorts UNICODE in simplified Chinese characters. The second half of the sorting rule is the suffix meaning:
_ BIN binary sorting
_ CI (CS) is case sensitive, CI is case insensitive, and CS is case sensitive: select this option if you want to compare uppercase and lowercase letters.
_ Whether AI (AS) is accent-sensitive, while AI is not. AS is accent-sensitive: select this option if you want to treat accent and non-accent letters AS different. If this option is selected, the comparison also treats letters with different accents as unequal.
Whether the _ KI (KS) class is Kana-type. kks-type is Kana-type. Kana-type is Kana-type. If you want to compare the Katakana and Japanese syllables, select this option.
_ WI (WS) Whether to differentiate width without WI, WS distinguishes between width: select this option if you want to compare half-width and full-width characters.