Again about SQL

JJM

Active Member
Licensed User
Longtime User
Hi,

cmd.CommandText="INSERT INTO " & NomF & " VALUES " & "('" & TextBox3.Text & "','" & TextBox4.Text & "')"

If TextBox3.text="Hello" I get no error
but if Textbox3.text="Hello, how are you" I get an error because of the comma and it's the same thing if TextBox contains an apostrophe.
(idem for Textbox4.text, of course!)

Could you hepl me ?

Thanks

JJM
 

maXim

Active Member
Licensed User
Longtime User
Hi JJM,

:sign0013: for my english...

verifies the command string with this syntax:

"INSERT INTO TableName(FieldName1, FieldName2, ...) VALUES ('FieldValue1', 'FieldValue2', ...)"

if omitted the fields name (FieldName?): all the values (FieldValue?) must be inserts in sequence and also the type has to correspond...

regards,
maXim
 
Last edited:

JJM

Active Member
Licensed User
Longtime User
Thank you,

It's not the syntax of the sentence who's wrong but the content of the column.
The content seems not to accept coma or/and apostroph. If I replace comma by '-' or by '_' iI get no error.
Is there an option which one I can use comma?

Best regards and :sign0085:

JJM
 

dzt

Active Member
Licensed User
Hello,

It looks like nothing is wrong about the comma. Onle take care to enclose strings inside apostrophs.

To solve ' problem add one more next to the first:
'JJM's app' -> 'JJM''s app'

regards
 

JJM

Active Member
Licensed User
Longtime User
Thanks Dimitris,

The error was with the apostroph. In the cell there were a comma and an apostroph and of course i got an error.

Thanks again for your help.

Best regards

JJ M
 
Top