I'm trying to insert some data into a MySQL database using the below C# code. If I run this command it throws an exception like the following:
some error: You have an error in your SQL syntax; check the manual that correspo
nds to your MySQL server version for the right syntax to use near ': The Third Reich,
,
' at line 25
Is there a syntax error somewhere? I can't find anything wrong.
var rowContent = String.Format(@"
INSERT INTO animes
(
`JapanTitle`,
`AmericanTitle`,
`GermanTitle`,
`AnimeType`,
`CoverPath`,
`Episodes`,
`MinutesPerEpisodes`,
`JapanStatus`,
`AmericanStatus`,
`GermanStatus`,
`JapanTimeSpan`,
`AmericanTimeSpan`,
`GermanTimeSpan`,
`MainGenres`,
`SubGenres`,
`JapanStudios`,
`AmericanStudios`,
`GermanStudios`,
`GermanDescription`,
`EnglishDescription`)
VALUES
({0},
{1},
{2},
{3},
{4},
{5},
{6},
{7},
{8},
{9},
{10},
{11},
{12},
{13},
{14},
{15},
{16},
{17},
{18},
{19});", entity.JapanTitle,
entity.AmericanTitle,
entity.GermanTitle,
entity.AnimeType.ToString(),
entity.WallPaper.FileName,
entity.Episodes,
entity.MinutesPerEpisode,
entity.JapanStatus.ToString(),
entity.AmericanStatus.ToString(),
entity.GermanStatus.ToString(),
entity.JapanTimeSpan.ToString(),
entity.AmericanTimeSpan.ToString(),
entity.GermanTimeSpan.ToString(),
string.Join(",", entity.MainGenres),
string.Join(",", entity.SubGenres),
string.Join(",", entity.JapanStudios),
string.Join(",", entity.AmericanStudios),
string.Join(",", entity.GermanStudios),
entity.GermanDescription,
entity.EnglishDescription);
If I look at this code, I think it is pretty bad code. Is there a better way to insert many columns into a database without something like the entity framework?