Tokfrans
Tokfrans

Reputation: 1959

Syntax error in sqlite insert query when trying to insert data with quote symbol

I'm pretty new to the world of Databases. And I'm trying to fill a local database with my local music library. Here's what the table looks like (the string I used to create it)

string sql = ("CREATE TABLE music (searchpaths VARCHAR(20), artists VARCHAR(20), album VARCHAR(20), track VARCHAR(20), year INT, duration INT, tracknumber INT)");

But I'm getting this error (see title of question) when trying to fill the database.

I always seem to get it on the same song. Here's what that "INSERT" string looks like:

"INSERT INTO music (searchpaths, artists, album, track, year, duration, tracknumber) values ('E:\\Music\\01 I Don't Deserve You (Seven Lions Remix) [Radio Edit].mp3', 'Paul van Dyk', 'I Don't Deserve You Remixes', 'I Don't Deserve You (Seven Lions Remix) [Radio Edit]', 2012, 226, 7)"

If there's any more info you need, please tell me. Thanks

Upvotes: 1

Views: 623

Answers (1)

Travis
Travis

Reputation: 10547

Since your content also contains single quotes, it's getting jammed up. You can do '' two quotes to escape words like don't.

Though the better answer is to use queries with parameters instead of raw SQL strings.

Upvotes: 1

Related Questions