Click here to Skip to main content
13,867,096 members
Rate this:
 
Please Sign up or sign in to vote.
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 19: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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Bit field != boolean field.
Try a 0.
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190214.1 | Last Updated 23 Jan 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100