public static void StoreGrid(ICAUploadDAO result) { string queryString = "INSERT INTO Result (ModuleGrp, PEM, AdmNo, Name, ICA1, ICA2, ICA3, ICA4, ModuleCode) values ('" + @result.ModuleGrp + "','" + @result.PEM + "','" + @result.AdmNo + "','" + @result.Name + "','" + @result.ICA1 + "','" + @result.ICA2 + "','" + @result.ICA3 + "','" + @result.ICA4 + "','" + @result.ModuleCode + "')"; string connectionString = Properties.Settings.Default.DBConnection; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(queryString, connection); connection.Open(); command.ExecuteNonQuery(); } }
I would like to check if the line exists before the insert, if it exists, then she would like to update it. I would be very grateful if someone could help me with this, because I do not know how to do this. Thank you very much.
source share