示例#1
0
        public static void ModifyArchive(string currentRow)
        {
            var newArray = new List <DataSql>();

            // Connect to the Database
            using (SqlConnection sqlConn = new SqlConnection(_connectionString))
            {
                string cmdString = "SELECT * FROM [dbo].[ArchivesV2] WHERE ID = @val1";
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = sqlConn;
                    cmd.CommandText = cmdString;
                    cmd.Parameters.AddWithValue("@val1", currentRow);

                    sqlConn.Open();

                    var dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        DataSql dataSql = new DataSql
                        {
                            Cote          = dr["cote"].ToString(),
                            Versement     = string.IsNullOrEmpty(dr["versement"].ToString()) ? new DateTime(1900, 1, 1) : Convert.ToDateTime(dr["versement"].ToString()),
                            Etablissement = dr["etablissement"].ToString(),
                            Direction     = dr["direction"].ToString(),
                            Service       = dr["service"].ToString(),
                            Dossiers      = dr["dossiers"].ToString(),
                            Extremes      = dr["extremes"].ToString(),
                            Elimination   = dr["elimination"].ToString(),
                            Communication = dr["communication"].ToString(),
                            Localisation  = dr["localisation"].ToString()
                        };
                        newArray.Add(dataSql);
                    }
                }
            }
        }