无法使用.net插入oracle(ORA 00911错误)

时间:2014-05-30 06:51:32

标签: c# sql .net oracle11g

所以,我正在使用.NET和oracle 11g express构建一个C#应用程序。我已经连接到数据库,但由于某种原因,它无法插入数据库,它一直给出ORA 00911错误。这是代码:

    private void toolStripButton1_Click(object sender, EventArgs e)
    {
        string salvar;           
        dbConnection conn = new dbConnection();
        try
        {
            conn.tryconection();
            salvar = "INSERT INTO Client(Name, Document, City, Contact, Addr, District, Zipcode, Phone_1, Phone_2, Cel_1, Cel_2, eymael, tobar) VALUES('" + boxNome.Text + "', '" + boxDocumento.Text + "','" + boxCidade.Text + "','" + boxContato.Text + "','" + boxEndereco.Text + "','" + boxBairro.Text + "','" + boxCep.Text + "','" + boxFone1.Text + "','" + boxFone2.Text + "','" + boxCel1.Text + "','" + boxCel2.Text + "','" + boxEmail.Text + "','" + boxComment.Text + "');";
            //MessageBox.Show(salvar);
            conn.executaInstrucao(salvar);
            //conn.executaInstrucao("commit;");
        }
        catch (Exception g)
        {
            MessageBox.Show("Problema na conexão");
        }

    }

这是带有一些随机值的输出字符串,可以在SQL Developer上运行并实际添加行:

INSERT INTO Client(Name, Document, City, Contact, Addr, District, Zipcode, Phone_1, Phone_2, Cel_1, Cel_2, eymael, tobar) VALUES('asdassdsad', '15.465.465/4654-54','654654654','654654654','654654654','654654654','65465-465','(65) 4654-6546','(54) 6546-5465','(46) 54654-6546','(65) 46546-5465','4654654654','65465465465');
请帮助我的人。我不知道出了什么问题。

PS:我的所有专栏都是VARCHAR2。

1 个答案:

答案 0 :(得分:0)

ORA 00911是无效的char问题。如果你的文本框中有'char',可能会出问题。像上面的评论一样使用SqlCommand.Parameters.AddWithValue就像SonerGönül所说parameter