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

C# 无法使用.net插入oracle(ORA 00911错误),c#,sql,.net,oracle11g,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();

因此,我正在使用.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');
谁来帮帮我。我不知道怎么了


注:我的所有列都是VARCHAR2。

ORA 00911是无效字符问题。如果您的文本框中有“char”,可能会产生问题。像上面的评论一样,使用SqlCommand.Parameters.AddWithValue,就像Soner Gönül所说的

首先,您应该始终使用。这种字符串连接是可以被攻击的。就这么做了。谢谢你的帮助。它在参数化方面做得很好,但实际的问题是最后的“;”。非常愚蠢的错误,哈哈。谢谢你,善良的先生。