Dear guys,

This code causes firebird to use all the OS memory until it crashes. What I
think is most interesting is that it is not my application that is using the
memory but the fbserver.exe process.

Am I doing anything wrong? It is a mantenance program, the idea is to
reorganize all the city names that appear more than once into a single city
in the database i.e. kill duplicates.

Is not FB supposed to free its memory? It is my second .net program that
crashes the computer because of FB is taking all the memory. I am using the
client 2.5.2
 and FB2.13

It happened so far with Windows 7 and windows server 2003.

Many thanks
-Evandro


        private void btnCorrigirCidades_Click(object sender, EventArgs e)
        {
            configuracaoSalvar();
            D.Bd = new Bd();
            D.Bd.ConStr = D.ConexaoParamentros();
            try
            {
                D.Bd.Connect();
            }
            catch (Exception ex)
            {
                NeoDebug.Debug.ErrorRecord("Não foi possível conectar ao
banco de dados " + ex.Message + " " + ex.StackTrace);
                NeoException.FE.Show("Não foi possível conectar ao banco de
dados ", "Erro", ex.Message + " " + ex.StackTrace);
                System.Environment.Exit(1);
            }

            DataTable completo = D.Bd.DataTablePreenche("select CODIGO,
DESCRICAO, COD_UF FROM CIDADE ORDER BY CODIGO DESC");
            string antes, depois="";
            for (int y = 0; y < completo.Rows.Count; ++y)
            {
                antes = D.Bd.T("Select DESCRICAO FROM CIDADE WHERE CODIGO =
" + completo.Rows[y][0]);
                depois = RemoverAcentos(antes.ToUpper().Trim());
                D.Bd.ExecuteNonQuery("UPDATE CIDADE SET DESCRICAO = '" +
depois + "' where CODIGO = " + completo.Rows[y][0]);
            }


            List<int> cLst;
            FbTransaction dbTrans = null;
            for (int y = 0; y < completo.Rows.Count; ++y)
            {
                cLst = D.Bd.LstI("Select CODIGO FROM CIDADE WHERE COD_UF =
'" + completo.Rows[y][2] + "' and TRIM(UPPER(DESCRICAO)) = TRIM(UPPER('" +
completo.Rows[y][1].ToString().Replace("'", "''") + "'))");
                if (cLst.Count > 1)
                { // repetido
                    for (int z = cLst.Count - 1; z >= 1; --z)
                    {
                        using (dbTrans = D.Bd.Con.BeginTransaction())
                        {
                            D.Bd.ExecuteNonQuery("update fornecedor F SET
F.cod_cidade = " + cLst[0] + " WHERE F.cod_cidade = " + cLst[z], dbTrans);
                            D.Bd.ExecuteNonQuery("update cliente C SET
C.cod_cidade = " + cLst[0] + " WHERE C.cod_cidade = " + cLst[z], dbTrans);
                            D.Bd.ExecuteNonQuery("update cliente C SET
C.cod_cidade_cobranca = " + cLst[0] + " WHERE C.cod_cidade_cobranca = " +
cLst[z], dbTrans);
                            D.Bd.ExecuteNonQuery("update FUNCIONARIO f set
f.COD_CIDADE = " + cLst[0] + " where F.cod_cidade =  " + cLst[z], dbTrans);
                            D.Bd.ExecuteNonQuery("update loja l set
l.COD_CIDADE = " + cLst[0] + "  where l.cod_cidade =  " + cLst[z], dbTrans);
                            D.Bd.ExecuteNonQuery("DELETE FROM CIDADE where
CODIGO =" + cLst[z], dbTrans);
                            dbTrans.Commit();
                        }
                    }
                }
            }

            D.Bd.ExecuteNonQuery(@"CREATE UNIQUE INDEX IDX_CIDADE_DESCRICAO
                                    ON CIDADE (DESCRICAO, COD_UF)");
            MessageBox.Show("Cidades com nomes normalizados :) !!!" +
"Cidades remanejadas e indíce único criado para não permitir descrições
repetidas, favor confirmar no ibexpert :) !!!");

         }



        public string RemoverAcentos(string texto)
        {
            string s = texto.Normalize(NormalizationForm.FormD);

            StringBuilder sb = new StringBuilder();

            for (int k = 0; k < s.Length; k++)
            {
                UnicodeCategory uc =
CharUnicodeInfo.GetUnicodeCategory(s[k]);
                if (uc != UnicodeCategory.NonSpacingMark)
                {
                    sb.Append(s[k]);
                }
            }
            return sb.ToString();
        }
------------------------------------------------------------------------------
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
  • ... Evandro's mailing lists (Please, don't send personal messages to this address)
    • ... Jiri Cincura
      • ... Evandro's mailing lists (Please, don't send personal messages to this address)
        • ... Jiri Cincura

Reply via email to