3
I’m having trouble saving file address in the database. When saving the address in the bank it is adding the amount of times I used the OpenFileDialog to save a file.
Always save the address like this  C:\Users\phili\Desktop\PDF_SGIM_QUALIDADE_CNH\certificadocalibracao.pdf12 
Always put a numeral after the extension.
Why is this happening?
private void tsbtnGravar_Click(object sender, EventArgs e)
        {
            try
            {
                if (identificacaoTextBox.Text == "")
                {
                    MessageBox.Show("Informe a Identificação do Instrumento.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    identificacaoTextBox.Focus();
                }
                else if (descricaoTextBox.Text == "")
                {
                    MessageBox.Show("Informe s Descrição do Instrumento.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    descricaoTextBox.Focus();
                }
                else
                {
                    if (status == "novo")
                    {
                        cmd.CommandText = "INSERT INTO tb_Intrumento (identificacao,Descricao,Marca, Modelo,Serial,Capacidade,Frequencia,Data_Calibracao,Vencimento_Calibrecao,Certificado) VALUES('" + identificacaoTextBox.Text + "','" + descricaoTextBox.Text + "','" + marcaTextBox.Text + "','" + modeloTextBox.Text + "','" + txb_Numero_Serie.Text + "','" + capacidadeTextBox.Text + "','" + tcb_Frequencia_Calibracao.Text + "','" + txb_Data_Calibracao.Text + "','" + txb_Vencimento_Calibracao.Text + "','" + txb_caminho.Text + "','" +
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();
                        MessageBox.Show("Registro salvo com sucesso.", "Salvar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (status == "editar")
                    {
                        cmd.CommandText = "INSERT INTO tb_Instrumento SET Identificacao='" + identificacaoTextBox.Text + "',  Descricao='" + descricaoTextBox.Text + "',Marca='" + marcaTextBox.Text + "', Modelo='" + modeloTextBox.Text + "', Serie='" + txb_Numero_Serie.Text + "', Capacidade='" + capacidadeTextBox.Text + "', Frequencia='" + tcb_Frequencia_Calibracao.Text + "', Data_Calibracao='" + txb_Data_Calibracao.Text + "', Vencimento_Calibracao='" + txb_Vencimento_Calibracao.Text + "', Certificado='"  + txb_caminho.Text +
                             lstvInstrumentos.Items[lstvInstrumentos.FocusedItem.Index].Text + "'";
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Registro atualizado com sucesso.", "Atualizar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    carregaVariaveis();
                    btn_Limpar_Dados.PerformClick();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Below follows code that inserts the path in the textbox:
private void btn_Carregar_Certificado_Click(object sender, EventArgs e)
        {
            OpenFileDialog abrir = new OpenFileDialog();
            abrir.ShowDialog();
           // openFileDialog1.ShowDialog();
            txb_caminho.Text = abrir.FileName.Replace(@"\", @"\\");
        }
Aside from the huge security problem, the names of variables that do not follow the C# nomenclature pattern and I don’t understand why the
Replace, I didn’t see why this is happening. As far as I know the propertyFileNamedoes not generate this on its own. Try to isolate the problem.– Maniero
I removed replace, but still the error continues. When saving the path in the database it adds the numeral after the end of the path.
– Philipe Said