| |

VerySource

 Forgot password?
 Register
Search
View: 1794|Reply: 15

Brothers who have research on the garbled problem come in

[Copy link]

1

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-25 12:00:02
| Show all posts |Read mode
The cause of the problem is:

My website system has such a function:
To query user information by querying the user account.
When the user name is English, there is no problem, but when the user name is Chinese, no information can be found.
So I did some work and found some problems.

(1) I checked the pull stored procedure and verified it directly with the Chinese name in the database. No problem.
The executed statement is as follows
. . . . .
exec process name, @username process parameter = N'user name '-N stands for unicode encoding
. . . . .
(2) So I opened sql server profiler to monitor. Then I visited the webpage and found the calling statement shown below:
. . . . .
exec procedure name, @username procedure parameter = '? ? ? '-The difference from the above is that one N is missing, resulting in garbled characters.
. . . . .
(3) The key to solving the problem now is how to enable the database to execute the statement in (1) when the query comes directly from the website.
Reply

Use magic Report

1

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-2-13 21:00:02
| Show all posts
The website system coding uses UTF-8, and tests show that there is no garbled code before transmission to the database process, everything is normal.
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-2-13 21:15:01
| Show all posts
Multilingual version is best to use unicode type
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-2-14 06:45:01
| Show all posts
exec process name, @username process parameter = N'user name '
// Is this sentence written directly in sql or in the form of parameter addition?
Reply

Use magic Report

1

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-2-16 22:15:01
| Show all posts
Describe again:
(1) I checked the pull stored procedure, and executed the procedure in the database. Input Chinese name parameters to verify that there were no problems.
The resulting execution statement is as follows
. . . . .
exec process name, @username process parameter = N'user name '-N stands for unicode encoding
. . . . .
(2) So I opened sql server profiler to monitor. Then I visited the webpage and found that the calling statement displayed by sql server profiler was as follows:
. . . . .
exec procedure name, @username procedure parameter = '? ? ? '-The difference from the above is that one N is missing, resulting in garbled characters.
. . . . .
(3) The key to solving the problem now is how to enable the database to execute the statement in (1) when completing the query from the website.
Reply

Use magic Report

1

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-2-16 22:30:01
| Show all posts
Describe again:
(1) I checked the pull stored procedure, and executed the procedure in the database. Input Chinese name parameters to verify that there were no problems.
The resulting execution statement is as follows
. . . . .
exec process name, @username process parameter = N'user name '-N stands for unicode encoding
. . . . .
(2) So I opened sql server profiler to monitor. Then I visited the webpage and found that the calling statement displayed by sql server profiler was as follows:
. . . . .
exec procedure name, @username procedure parameter = '? ? ? '-The difference from the above is that one N is missing, resulting in garbled characters.
. . . . .
(3) The key to solving the problem now is how to enable the database to execute the statement in (1) when completing the query from the website.
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-2-17 15:15:01
| Show all posts
Directly with command.Text = "exec process N'name '"

Don't @ parameter =
Reply

Use magic Report

0

Threads

58

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-2-17 21:15:01
| Show all posts
If you pass parameters, the parameter type is nvarchar. If you use SQL string concatenation, refer to the above.
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-2-18 13:00:01
| Show all posts
If the database uses unicode storage, the parameter value must also use utf-8, which can be used before querying
encoding.getstring () for conversion
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-20 19:15:01
| Show all posts
First determine if you have to use unicode, it seems that the demand is not too much. Sure, but maybe you do n’t need it at all
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list