SQL Statement to insert a single quote i.e., ' into a column of the into MSAccess table
Hi
I am trying to insert the file path which has a ' into a column of the table master
I have used the below code:
INSERT INTO Master ( Recno, Path )
VALUES (83, [F:\Shashi Works\ltctgebswcode_Mseb\Data\Venkat's Data\Data260407105547.Dat]);
When I try with
INSERT INTO Master ( Recno, Path )
VALUES (83, "F:\Shashi Works\ltctgebswcode_Mseb\Data\Venkat's Data\Data260407105547.Dat"); the ODBC is converting " to [ as the above code
at runtime and I am getting the error
Runtime error '-2147217900 980040e14)': [Microsoft][ODBC Microsoft Access Driver] Invalid bracketing of name
Usually the single quote character is reserved for inserting information into a database and so if a single quote is contained in the actual data to be inserted, the command often becomes corrupted. To solve the problem simply replace any single quote with two quotes (not the double quote character but two single quote characters. The sample command below performs this replacement automatically:
sContent = Replace(sContent,"'","'")
where sContent contains the data that needs single quotes replaced so that the data can be inserted into a database.
I have this problem, but this time not with a single quote, but with a comma (,).
Should it be replaced by ',' or ,,?
this is impossible dude. Commas inside a SQL statement are allowed. The statement for example: sql = "This is a new SQL statement, containing a Comma!" would be saved correctly.You are most likely having a problem with the database or code around this.Just send a quick sample of this problem in context, then we can have a look and see what the problem might be.Cheers