Click here to Skip to main content
15,887,414 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I work on csharp application i have case need to update bit field with label control

.text so thatwhen 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 :

update [dbo].[AccBranch] set savedata=false


so when save data is bit datatype on sql so that to assign value must be

savedata='false' not savedata=false

so that i need to have single quotes on value .

i also not need single quotes within update statement .

I need label control .text save value with single quotes meaning store 'False'

how to do that please ?

What I have tried:

label1.text='False';

it give me compile error
label1.text="False"

it saved without single quotes so nthat update give me
error synatx
Posted
Updated 22-Jan-19 18:43pm
v2
Comments
Bryian Tan 22-Jan-19 23:40pm    
I'm lost :) , Have you try label1.text="'False'"?
Richard MacCutchan 23-Jan-19 5:42am    
You must use double quotes to set a text field to a string. If you want to set it to the value of a number, or some object, then you need to use the object's ToString() method to get a text value.
Richard Deeming 24-Jan-19 8:51am    
It sounds like you're concatenating the label text into a SQL query, rather than using parameters.

1 solution

Bit field != boolean field.
Try a 0.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900