473,902 Members | 6,000 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12198
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.c om 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******** *************@z 14g2000cwz.goog legroups.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
2648
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 - Nicolaas
4
5249
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 "" Now a few weeks ago there was a similar problem with the boolean value. That's when the tcl started returning "???" for unknown fields in a
4
6197
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 is the format for a boolean value? E.g. <..name.. Enabled=??? />
2
2093
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 subforms. Toggle1 selects Subform2
3
6067
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 do something like ... = MyDataReader.GetBoolean; since I don't always know the field number of the IsLocked field. Why is
4
2525
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 chkDebtor.DataValueField = "checked" -- this is a column in the table that returns 1 or 0 chkDebtor.DataTextField = "DebtorCode" chkDebtor.DataBind() Dim i As Integer = 0 While i < chkDebtor.Items.Count
2
3420
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 this since the rowfilter is a string? i tried dv.rowfilter = "Works = " & b_DoesWork and get errors back in the IDE that says
1
6673
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
19816
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
1646
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 means it supposed to print out 'false' but it's giving 'true' value and vice versa. Please refer my Driver class (excerpt):java.util.List ifs = new java.util.ArrayList(); Instruction insn = jvm.getLastInstruction(); ……… ……… if (insn...
0
9997
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9845
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9675
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7205
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4307
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3323
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.