I'm trying to do is an automation, that receives data in a datagridview and after that, my current problem, saving it in sql I already made some experiments, what I got so far is this,
GDataPicker();
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = conn;
conn.Open();
for (int x = 0; x < dataGridView1.Rows.Count; x++)
{
string strquery = @"INSERT INTO table_teste1 VALUES ("
+ dataGridView1.Rows[x].Cells["Rua"].Value + ", "
+ dataGridView1.Rows[x].Cells["Código Postal"].Value + ", "
+ dataGridView1.Rows[x].Cells["Distrito"].Value + ", "
+ dataGridView1.Rows[x].Cells["Concelho"].Value + ", "
+ dataGridView1.Rows[x].Cells["Freguesia"].Value + ", "
+ dataGridView1.Rows[x].Cells["GPS"].Value + ");";
cmd.CommandText = strquery;
cmd.ExecuteNonQuery();
}
}
conn.Close();
the problem with this code is that I keep receiving this -> System.Data.SqlClient.SqlException: 'Incorrect syntax near 'de'.'
Could anyone try to help me, thanks.