473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Boolean to Value for SQL

When I try to insert values from a boolean into SQL I keep getting this
error.

The name 'True' is not permitted in this context. Only constants,
expressions, or variables allowed here. Column names are not permitted

"INSERT INTO table (bitColName) VALUES ('" & boolValue & "')
Is there an easier way to convert the boolean value to 0 or 1 than
using the long approach of creating an integer and setting that to 0 or
1 depending on the boolean?

Nov 21 '05 #1
6 12144
Ree,

Use parameters, have a look at the simple sample for this on our website.
There are as well two more extended samples.

http://www.windowsformsdatagridhelp....6-7139b8970071

Cor
Nov 21 '05 #2
re***@hotmail.com wrote:
When I try to insert values from a boolean into SQL I keep getting this
error.

The name 'True' is not permitted in this context. Only constants,
expressions, or variables allowed here. Column names are not permitted

"INSERT INTO table (bitColName) VALUES ('" & boolValue & "')
Is there an easier way to convert the boolean value to 0 or 1 than
using the long approach of creating an integer and setting that to 0 or
1 depending on the boolean?


"INSERT INTO table (bitColName) VALUES ('" & iif(boolValue,"1","0") & "')
Nov 21 '05 #3
Thanks I was hoping for simple solution in VB.net rather than the SQL.

C-Services Holland b.v. wrote:

"INSERT INTO table (bitColName) VALUES ('" & iif(boolValue,"1","0") & "')


Nov 21 '05 #4
As an alternative you could use:

Math.Abs(CType(boolValue, Integer))
<re***@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Thanks I was hoping for simple solution in VB.net rather than the SQL.

C-Services Holland b.v. wrote:

"INSERT INTO table (bitColName) VALUES ('" & iif(boolValue,"1","0") & "')

Nov 21 '05 #5
Bob
Cor:

How does a date param pertain to BOOL field?

Bob
Nov 21 '05 #6
Thanks

Stephany Young wrote:
As an alternative you could use:

Math.Abs(CType(boolValue, Integer))


Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WindAndWaves | last post by:
Hi Gurus What is the best way to store a boolean value in a MySql table (e.g. true or false) AND ( ;-) am I asking this in the right newsgroup (I could not find one for MySQL) Thank you -...
4
by: Grzegorz Dostatni | last post by:
Good morning. I've got a Tkinter problem: File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 2310, in selection_present return self.tk.getboolean( TclError: expected boolean value but got "" ...
4
by: Simon Jefferies | last post by:
Hello, I've created an XSD file with the following in it: <xs:attribute name="Enabled" form="unqualified" type="xs:boolean" /> I am trying to set the XML to match this format, but how/what...
2
by: Douglas Buchanan | last post by:
This is a mystery! Why does the boolean value of a record change without my input. What follows describes the situation and the behavior. Table1: Field1: Text Field2: Yes/No Form1 has two...
3
by: Daves | last post by:
trying to get a boolean value from DataReader (that is, result from a SQL query); boolean MyBool = MyDataReader.GetBoolean(3); well it works using that number 3 but of course I would like to...
4
by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR...
2
by: Brian Henry | last post by:
say i have a dataset called dv and i have a boolean value i want to filter by "b_DoesWork" while the column name in the data view that i want to filter on is called "Works" how would i filter...
1
by: STAGED | last post by:
The script: proc bugsy { } { global helmet pack forget .widget1 if { $helmet(key1) } { pack .widget2 -anchor nw -side top -expand 0 } else { show_new_widget }
4
by: moondaddy | last post by:
I'm new to c# and want to know the preferred way to reverse a Boolean value. for example: in vb I can do this: dim flag as Boolean
5
by: shana07 | last post by:
Good day all! I have one more question and needed some inputs from you guys. This is regarding condition value (T/F). My program (Driver) prints out condition values in reversed way - which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.