I'm trying to insert data into a SQL Server CE local database but having an issue I can't solve for the life of me.
foreach (var player in cells)
{
var sql = new SqlCeConnection(
@"Data Source=H:\Repositories\NHL-Connected\NHLConnected\NHLScraper\app.sdf");
try
{
sql.Open();
var cmd =
new SqlCeCommand("INSERT INTO Players (PlayerID, PlayerName, Team_Abbreviation) Values ( '" +
player.ID.Replace("/ice/player.htm?id=", null) + "," + player.Name + "," +
player.Team + "')", sql);
int affectedRows = cmd.ExecuteNonQuery();
if (affectedRows > 0) Console.WriteLine("Successful.");
else Console.WriteLine("Failed.");
}
catch (SqlCeException ex)
{
Console.WriteLine(ex.Message);
}
}
The exception/error I'm getting is
The count of column names and source expressions do not match [Column name count = 3, Source expression count = 1]
I'm unsure if I'm doing this correctly.
Please advise.