I am trying to save some data into an SQLite database, but I am having a problem actually saving the data to the database , the error i am facing is that my data cannot be saved into my database
Here is my current code: I do really need help in this because I really have no idea where it goes wrong
SQLiteConnection con = new
SQLiteConnection("DataSource=|DataDirectory|\\trendchart.db");
con.Open();
for (int i = 0; i < dataGridView1.Rows.Count ; i++)
{
try
{
SQLiteCommand g = new SQLiteCommand("INSERT INTO data(TOP(1), TOP(2) VALUES ('" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "" +
dataGridView1.Rows[i].Cells[1].Value.ToString() + "" +
dataGridView1.Rows[i].Cells[2].Value.ToString() + "" +
dataGridView1.Rows[i].Cells[3].Value.ToString() + "')", con);
g.ExecuteNonQuery();
MessageBox.Show("DataSaved please check if its correct ");
}
catch
{
MessageBox.Show("Error 404");
}
}