Re: Newbie, True and False
- From: "tclancey" <tull@xxxxxxxxxxxxxxxx>
- Date: Sat, 31 Mar 2007 15:39:27 +0100
Sorry, tired when I wrote this last night. Let me explain a little better.
The application I'm working on at the moment needs to connect to Access,
MsSql or MySql, this will be decided by the customer and set in the software
by a hardware key.
I have started conversion of the code that was originaly written for Access.
All commands, Insert, Update etc work fine with MySql, but not with MsSql.
The only real problem that I can see is the True and False fields. I really
don't want to have to write completely seperate routines for each database
back end.
Also, pulling in a field and setting a CheckBox.Checked state to True or
False is easy if the return value is True or False.
I have thought about writing some kind of parser to check for certain
keywords and replace them, but I cannot guarantee that the users are not
going to use the words True, Flase or even 1 or 0.
Any help would be greatfully recevied as I currently have no idea how to get
around this!
Thanks,
Tull.
"tclancey" <tull@xxxxxxxxxxxxxxxx> wrote in message
news:OlVQoJxcHHA.3484@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for your reply.
I understand my expression of the problem was somewhat limited, I thought
there would be an easy answer that I've missed.
If I explain the following it may make more sense, or at least give a
better idea of what I want to achieve.
I have an application that I need to work with Access (currently it does,
very well) MySql and MsSql.
I can get all True/False queries to work with MySql without any problems
using exactly the same syntax as Access. MsSql is the problem. There
simply isn't a Boolean return field available.
There must be a simple answer somewhere as I'm sure other people have
faced the same problem.
The 'bit' field in MySql handles True and False correctly. Why can't MS?
"Scott Morris" <bogus@xxxxxxxxx> wrote in message
news:OaQm7LwcHHA.1508@xxxxxxxxxxxxxxxxxxxxxxx
"tclancey" <tull@xxxxxxxxxxxxxxxx> wrote in message
news:%23z5at5vcHHA.4820@xxxxxxxxxxxxxxxxxxxxxxx
Hi All.
First time working on an SQL database. I'm able to create all my tables
and fields without errors. I can work eith the back end pretty well,
but I can't work out True or False Fields/Columns.
If I try:
Insert Into MyTable (value1, value2) values (true, false);
I'm told that true (or false) cannot be used as they are column names or
keywords.
Brace yourself. What does "I'm told" mean? A rhetorical question - this
time I think I know what is happening. In the future, you should quote
any errors exactly and completely and tell us exactly how you came to
encounter the error. Usually this means providing some clue about the
application you are using to execute queries. In addition, you should
always specify which version of sql server you are using alsong with the
SP level.
I've searched and searched for the answer, all the info I've found
pretty much contradicts itself!
Make a note of the "sources" that told you that you could use TRUE or
FALSE. Ignore them for all future information needs.
I'm using a Bit field, which surely should mean 1=True, 0=False. Does
with any other database.
What am I doing wrong? !!
Assuming that 1 = TRUE and that 0 = FALSE. They aren't. TSQL is not
C/C++/VB, there is no boolean datatype, and you cannot evaluate a number
(by itself) as a boolean expression. If you want to use a bit value of
1, then you must specify 1 (and not TRUE or "TRUE" or 'TRUE'). If you
have a background in Access, then there are many other things that you
will need to relearn when using sql server. I recommend you search (and
post to, if needed) the .programming NG since it is more focused on sql
server programming and experiences much higher volume.
.
- References:
- Newbie, True and False
- From: tclancey
- Re: Newbie, True and False
- From: Scott Morris
- Re: Newbie, True and False
- From: tclancey
- Newbie, True and False
- Prev by Date: Re: How to: Install Report Designer
- Previous by thread: Re: Newbie, True and False
- Next by thread: Re: Licensing through a TS
- Index(es):
Relevant Pages
|