Two things:
1) SQL syntax.
Your insert statement is:
string query = "";
query = "insert into singlebarcode values (";
foreach (string line in tblColumns)
{
query = query + "'" + line + "',";
}
string query1 = query.Substring(0, query.Length - 1);
query2 = query1 + ")";
Which amounts to:
string query2 = "INSERT INTO singlebarcode VALUES ('from excel')";
SQL syntax for an insert command requires the columns list:
string query2 = "INSERT INTO singlebarcode (myColumnName) VALUES ('from excel')";
2) Do not do it that way anyway! You leave yourself wide open for what is called an SQL Injection attack (Google "Bobby Tables" for find out what I mean). Use parametrized queries instead:
string query = "INSERT INTO singlebarcode (myColumn1, myColumn2) VALUES (@MC1, @MC2)";
SqlCommand command = new SqlCommand(query, Connection);
int i = 1;
foreach (string line in tblColumns)
{
command.Parameters.AddWithValue("@MC" + i.ToString(), line);
i++;
}
I suspect that you need to insert each line from the Excel file into a different row in you DB, but without seeing your DB layout, I can't tell.