codice:
string selectSQL1;
selectSQL1 = "select max(TipDoc), max(NDoc), max(Reg) from Documenti group by TipDoc, NDoc, Reg";
OleDbCommand cmd1 = new OleDbCommand(selectSQL1, conn);
OleDbDataReader reader1;
DataSet myDataSet1 = new DataSet();
OleDbDataAdapter myDataAdapter1 = new OleDbDataAdapter(selectSQL1, conn);
try
{
conn.Open();
reader1 = cmd1.ExecuteReader();
myDataAdapter1.Fill(myDataSet1, "Documenti");
con.Open();
foreach (DataTable table in myDataSet1.Tables)
{
foreach (DataRow row in table.Rows)
{
string thisQuery = "INSERT INTO Testa (Tipo, Numero, Registro) VALUES (@Tipo, @Numero, @Registro)";
SqlCeCommand thisCommand = new SqlCeCommand(thisQuery, con);
ECCEZZIONE----> thisCommand.Parameters.AddWithValue("@Tipo", row["TipDoc"]);
thisCommand.Parameters.AddWithValue("@Numero", row["NDoc"]);
thisCommand.Parameters.AddWithValue("@Registro", row["Reg"]);
thisCommand.ExecuteNonQuery();
}
}
}
questo è parte del mio codice funzionante però con la query suggerita, e l'eccezione che mi scatena è nella riga indicata...