Fórum Erro no INSERT com FIREBIRD #463354
08/12/2013
0
[img]http://arquivo.devmedia.com.br/forum/imagem/331292-20131208-182743.jpg[/img]
Vou postar aqui minha classe para salvar no Banco
public static void fb_InserirDados(Cliente cliente)
{
using (FbConnection conexaoFireBird = clsBanco.getInstancia().getConexao())
{
try
{
conexaoFireBird.Open();
string mSQL = "INSERT into Pessoa Values(" + cliente.ID + ",''''''''" + cliente.NOME + "'''''''',''''''''" + cliente.ENDERECO + "'''''''',''''''''" +
cliente.UF + "'''''''',''''''''" + cliente.CIDADE + "'''''''',''''''''" + cliente.BAIRRO + "'''''''',''''''''" + cliente.CEP + "'''''''',''''''''" +
cliente.CPF + "'''''''',''''''''" + cliente.CNPJ+ "'''''''',''''''''" + cliente.PROFISSAO + "'''''''',''''''''" + cliente.RESTRICOES + "'''''''',''''''''" +
cliente.EMAIL + "'''''''',''''''''" + cliente.TELEFONE + "'''''''',''''''''" + cliente.CELULAR + "'''''''',''''''''" +cliente.FAX+"'''''''')";
FbCommand cmd = new FbCommand(mSQL, conexaoFireBird);
cmd.ExecuteNonQuery();
}
catch (FbException fbex)
{
throw fbex;
}
finally
{
conexaoFireBird.Close();
}
}
}
E o codigo no botão salvar:
private void btnSalvar_Click(object sender, EventArgs e)
{
Cliente cliente = new Cliente();
cliente.ID = Convert.ToInt32(txtCodCliente.Text);
cliente.NOME = txtNome.Text;
cliente.ENDERECO = txtEndereco.Text;
cliente.UF = cbUF.Text;
cliente.CIDADE = txtCidade.Text;
cliente.BAIRRO = txtBairro.Text;
cliente.CEP = txtCep.Text;
cliente.CPF = txtCPF.Text;
cliente.PROFISSAO = txtProfissao.Text;
cliente.RESTRICOES = cbRestricoes.Text;
cliente.EMAIL = txtEmail.Text;
cliente.TELEFONE = txtTelefone.Text;
cliente.CELULAR = txtCelular.Text;
cliente.FAX = txtFax.Text;
try
{
clsBanco.fb_InserirDados(cliente);
preencheGrid();
MessageBox.Show("Cliente inserido com sucesso !", "Inserir", MessageBoxButtons.OK);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK);
}
}
Raniel Gomes
Curtir tópico
+ 0Posts
08/12/2013
Raniel Gomes
Gostei + 0
09/12/2013
Deivison Melo
Gostei + 0
09/12/2013
Raniel Gomes
Gostei + 0
09/12/2013
Douglas
ultrapassando o tamanho que você definiu na tabela.
Gostei + 0
09/12/2013
Raniel Gomes
Gostei + 0
09/12/2013
Raniel Gomes
ultrapassando o tamanho que você definiu na tabela.
Acabei de fazer isso mais ficar no mesmo jeito, já tentei sem as aspas simples, já tentei verificar o tamanho dos campos e nada.
Gostei + 0
09/12/2013
Raniel Gomes
CREATE TABLE PESSOA (
ID INTEGER,
NOME VARCHAR(200),
ENDERECO VARCHAR(150),
UF VARCHAR(10),
CIDADE VARCHAR(100),
BAIRRO VARCHAR(100),
CEP VARCHAR(8),
CPF VARCHAR(11),
CNPJ VARCHAR(14),
PROFISSAO VARCHAR(50),
RESTRICOES VARCHAR(50),
EMAIL VARCHAR(100),
TELEFONE VARCHAR(10),
CELULAR VARCHAR(10),
FAX VARCHAR(10)
);
Gostei + 0
09/12/2013
Raniel Gomes
ALTER TABLE PESSOA ADD CONSTRAINT PK_PESSOA PRIMARY KEY (ID);
Gostei + 0
09/12/2013
Raniel Gomes
Gostei + 0
10/12/2013
Douglas
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)