将Unicode插入SQL服务器 [英] Inserting Unicode into SQL server

查看:60
本文介绍了将Unicode插入SQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将BANGLA插入sql数据库。这是我的代码。

I need to insert BANGLA into sql database. Here is my code.

INSERT INTO [classTb] ([class]) VALUES (N'" + textbox01.Text+ "')



此插入命令有效,但只存储???不是BANGLA。我做错了什么?


This insert command work but it store only ??? not BANGLA. What wrong I have done?

推荐答案

首先,你已经对SQL注入攻击保持开放......不要连接字符串来构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。请改用参数化查询。



其次,检查 class 列是否声明为NVARCHAR而不是VARCHAR。 />


如果是,请查看用于检索数据的代码 - 可能存在问题。
Well, first off you have left yourself wide open to SQL Injection attacks... Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

Secondly, check that the class column is declared as NVARCHAR not VARCHAR.

If it is, look at the code you are using to retrieve the data - it may be that that has the problem.


这篇关于将Unicode插入SQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆