|
-
Jul 23rd, 2004, 02:00 AM
#1
Thread Starter
Junior Member
Problem with a ' in a databasefield. (SOLVED)
Hello,
I had a problem and I couldn't figure out what it was.
But after many mindbreaking I found out it was about a ' in a particular field.
I've got a Access database and in there is a table with a field of the Memo type. Now this field for example contyains the following text:
Many COA's have not been booked properly.
Result: A COA without values
Now it has an end of line but that isn't the problem I'm facing it's the '.
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Test' Test' Test''.
/Kamsystem/include/connect.asp, line 29
line 29 is the submitting of the Update querry.
I'm doing an UPDATE on a table with the memo field. If that field contains a ' it gives an error, I think it's because all the dfata behind the comma isn't inserted anywhere. So it cancels the update.
Shouldn't it be possble to have ' inserted and updated in a memo field?
I can't figure out how.
Thanks.
Last edited by ShotokanTuning; Jul 23rd, 2004 at 08:37 AM.
-
Jul 23rd, 2004, 04:06 AM
#2
Any time you put text data into SQL, replace any single quotes in the data with two single quotes (eg: '').
so to put in this text:
'Test' Test' Test'
you need to do something like this:
Code:
Update table Set field = '''Test'' Test'' Test'''
-
Jul 23rd, 2004, 04:56 AM
#3
Another alternative is using the Replace function to replace all single quotes (') with the apostrophy (`) which works well for storing text. Then you need the same replace on the search field to replace any single quotes before searching the db.
Just another option.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 23rd, 2004, 05:03 AM
#4
the trouble with that is that you are changing the data, replacing single quotes with two simply alters the SQL
-
Jul 23rd, 2004, 05:40 AM
#5
Thread Starter
Junior Member
This works when updating:
Function FormatText (inputText)
Dim textString, descr
dateString = inputText & ""
dateString = replace(dateString, "'", "''")
FormatText=dateString
End Function
Thanks for helping me out.
Last edited by ShotokanTuning; Jul 23rd, 2004 at 05:59 AM.
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
|