the character
Hello!
I have this code line to insert a name file in the database:
conn.Execute "INSERT INTO FILES (nome_fil) VALUES ('" & nome_file & "');"
If the name file have the character ' it doesn’t save the string in the database! It doesn't give any error!
Why does this happen?!
Thanks :)
[349 byte] By [
estrela666] at [2007-11-11 7:54:39]

# 2 Re: the character
As you'll notice from your INSERT statement, SQL uses the ' character to delimit data for string/text fields. [look just before and after your variable nome_file]. If the data contains the ' character, there are several ways to get SQL to include it in your database data. The easiest one I know is:
conn.Execute "INSERT INTO FILES (nome_fil) VALUES ('" & Replace(nome_file, "'", "''") & "');"
The second red text is 2 single ' characters, not 1 " character.