|
-
Apr 12th, 2007, 10:17 AM
#1
Thread Starter
Addicted Member
sql Syntax
I know that you put # round dates, ' around text and nothing around numbers when inserting into a database, what category does a memo box in access fall under. I seem to be having problems trying to get it to work in my code.
-
Apr 12th, 2007, 10:31 AM
#2
Hyperactive Member
Re: sql Syntax
Hi HelpLaura;
I just took a quick look at some code I have that adds text to a Memo field and it's simply delimited with '.
Perhaps you could post a bit more detail on what is happening.
-
Apr 12th, 2007, 10:32 AM
#3
Re: sql Syntax
A memo field contains text, so it uses '
-
Apr 12th, 2007, 10:33 AM
#4
Re: sql Syntax
The # around dates is only for MS Access database. Other DBs use different deliminaters for dates (most use a single qoute, but Oracle is different). What problems are you having?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 12th, 2007, 10:34 AM
#5
Thread Starter
Addicted Member
Re: sql Syntax
the other problem i have is that in one of my fields, it is for height the problem i have is that each time i produce an insert with 7'11 it bugs it up because of the ' is there any way that i can get round this? i tired putting ['7'11'] as well as '[7'11]' but doesn't like either of these
-
Apr 12th, 2007, 10:39 AM
#6
Re: sql Syntax
If you are using an Insert statement you need to replace each ' character in data with two, so you would have: fieldname = '7''11'
If you use a Command object with parameters, this (and similar issues) are not a problem. If you want to see how to do that, there is an example in our Database FAQs ("ADO: How do I add a record").
-
Apr 12th, 2007, 10:52 AM
#7
Re: sql Syntax
You will also find the same condition if you use 7'11" as the height. The single qoute needs to be replaced by tow single qoutes ( '' ) and the double qoute needs to be replace by four double qoutes ( """" ). So 7 feet 11 inches would look like this: 7''11""""
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 12th, 2007, 11:05 AM
#8
Thread Starter
Addicted Member
Re: sql Syntax
in my text box on my front end i have put 7''1 and then in my code i have tbl_suspect.height = '" txt_height.text & "'" but this doesn't work
Have i somehow miss understood what you mean? On my front end i only have one text box.
-
Apr 12th, 2007, 11:18 AM
#9
Re: sql Syntax
You'll need to show us a bit more code, as tbl_suspect.height doesn't appear to be valid code.
-
Apr 12th, 2007, 11:27 AM
#10
Thread Starter
Addicted Member
Re: sql Syntax
tbl_suspect.height = '" & txt_height.text & "'"
this code is part of my sql statement i am executing. This field a is not a number field, so when i tried it out with text in this field the code works fine. its those ' that are causing me problems. What other code do you need me to provide?
-
Apr 12th, 2007, 11:39 AM
#11
Re: sql Syntax
It would be much better to show us the entire line of code (and preferably a few before/after it too), and of course tell us details about why something "doesn't work".. eg: if there is an error, what is it?
From what you have told us, it looks like it should work (assuming the rest of that line of code is valid).
-
Apr 12th, 2007, 11:41 AM
#12
Re: sql Syntax
Try this:
tbl_suspect.height = '" & replace(replace(txt_height.text ,"'","''"),"""",""""") & "'"
Sometimes the Programmer
Sometimes the DBA
Mazz1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|