为什么我的文本框文本在表中插入原始文本? [英] Why is my textbox text inserting raw text to table?

查看:65
本文介绍了为什么我的文本框文本在表中插入原始文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从表中获取一个值并将其显示在标签中,然后将label.text插入数据库中的表中.

标签显示的内容如下:
AFCO圆形卷纸立柱6"X10",带衬板C&B

这是正确的,但是当我将label.text插入数据库时​​,它看起来像这样:
AFCO圆绕包装柱6; X10" W/SPLIT Camp; B

其将文本转换为原始文本?为什么是这样?以及我该如何解决?

i am getting a value from a table and displaying it in a label, then inserting the label.text into a table in the database.

This is what the label displays:
AFCO FLUTED ROUND WRAP COLUMNS 6"X10'' W/ SPLIT C&B

which is correct, but when i insert the label.text to database it looks like this:
AFCO FLUTED ROUND WRAP COLUMNS 6quot;X10'' W/ SPLIT Camp;B

its converting the text to raw? why is this? and how can i fix it?

推荐答案

它不会转换为原始".它是对文本进行编码,以使查询不会中断.
我猜您正在使用类似
It isn''t converting to "raw". It is encoding your text so that your query doesn''t break.
I''m guessing your using a query something like
var query = "INSERT INTO YourTable ... VALUES( " + yourValue + ")";


您应该使用参数化查询来解决这个问题.


You should be using a paramatarized query where this will be taken care of.

command.CommandText = "INSERT INTO YourTable ... VALUES( @yourValue )"; 
command.Parameters.AddWithValue("@yourValue", yourValueFromLabel);


这篇关于为什么我的文本框文本在表中插入原始文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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