Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert Single quotes in SQLite

I'm trying to add the following text to my database: Zeeland '96

But the single quote is giving me errors.

It should look like this:

INSERT INTO Department (Code, Name, CountryID) VALUES ('ZE', 'Zeeland '96', 1)

As you can see, at this moment is one quote missing, how can I get rid of this problem?

Thanks in advance!

like image 656
Max Avatar asked Sep 27 '26 16:09

Max


2 Answers

As you can see HERE you need to escape it by using two single quotes in a row. Try:

INSERT INTO Department (Code, Name, CountryID) VALUES ('ZE', 'Zeeland ''96', 1)
like image 151
letiagoalves Avatar answered Sep 30 '26 14:09

letiagoalves


Assuming you're using .NET Library, you can use the SQLiteParameter types to build an SQL command string.

like image 33
Anonymous Avatar answered Sep 30 '26 14:09

Anonymous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!