如何在label.text控件上使用单引号保存位字段的值 [英] How to save value on bit field with single quotes on label.text control

查看:119
本文介绍了如何在label.text控件上使用单引号保存位字段的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



    
   
我在c sharp应用程序上工作我需要用标签控件更新位字段 



.text这样当为标签控件赋值时,它更新而没有单引号



实际上我需要用单引号存储值 



label1.text =" False" ;;更新值但没有单引号 



当标记上存在有值的位字段的更新值时,它不会保存,因为 



它给我语法错误



语法错误发生,因为False设置如下:   
I work on c sharp application i have case need to update bit field with label control 

.text so that when assign value to label control it updated without single quotes

actually i need to store value with single quotes 

label1.text="False"; update value but without single quotes 

when updated value of bit field with value exist on label it not saved because 

it give me syntax error

syntax error happen because False set as following :   

Hide 复制代码

推荐答案

首先确保数据库列中的数据类型为
位,
然后在代码中我们需要传递 bool  到要在sql server上执行的数据库查询。我们可以在代码中轻松处理它:

First of all make sure in the database column the datatype of column is bit, then in the code we need to pass the bool  to the database query to be executed on the sql server. We can easily handle it in code something like:

label1.text="False"
bool isUpdated;
if(string.Equals(label1.text,"False",System.StringComparison.OrdinalIgnoreCase)
{
  isUpdated = false;
}
else
{
  isUpdated = true;
}

然后我们可以传递 isUpdated 到数据库查询参数。

and then we can pass the isUpdated to the database query parameter.

希望它能给出主意。


这篇关于如何在label.text控件上使用单引号保存位字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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