ORA-00926:C#上缺少VALUES关键字

时间:2016-03-29 03:44:04

标签: c# oracle

有些身体帮助我。我无法修复此错误,因为我不知道它在哪里出错。我被曝光但没有成功。错误是ORA-00926:在cmd.ExecuteNonQuery()之后错过了C#上的VALUES关键字;

string strInsert = @"Insert into INFOR_STUDENT(IdStudent, NameStudent, NameClass, IdClass, BirthStudent, SexStudent)  :IdStudent, :NameStudent, :NameClass, Select IdClass from Infor_Class where NameClass = :NameClass, :BirthStudent, :SexStudent";                

            OracleCommand cmd = new OracleCommand();
            //cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = strInsert;
            cmd.Connection = connIns;


            OracleParameter idClassParam = cmd.Parameters.Add("IdStudent", OracleDbType.Varchar2,
                ParameterDirection.Input);
            idClassParam.Value = tbxIdStudent.Text;


            OracleParameter nameClassParam = cmd.Parameters.Add("NameStudent", OracleDbType.Varchar2,
                ParameterDirection.Input);
            nameClassParam.Value = tbxNameStudent.Text;


            OracleParameter Si_soParam = cmd.Parameters.Add("NameClass", OracleDbType.Varchar2,
                ParameterDirection.Input);
            Si_soParam.Value = ddListClass.Text;


            OracleParameter birthStudent = cmd.Parameters.Add("BirthStudent", OracleDbType.Date,
                ParameterDirection.Input);
            birthStudent.Value = DateTime.ParseExact(tbxBirthSt.Text, "dd/mm/yyyy", CultureInfo.InvariantCulture);


            OracleParameter sexStudent = cmd.Parameters.Add("SexStudent", OracleDbType.Varchar2,
                ParameterDirection.Input);
            sexStudent.Value = ddListSex.Text;

            int row = cmd.ExecuteNonQuery();

2 个答案:

答案 0 :(得分:1)

正如错误消息所示,在指定表的所有列名后,尝试在static double AddSum() { double a = 0; double oldvalue; int i = 1; do { oldvalue = a; a += (i % 2 == 0) ? (double)-1 / (i + 1) : (double)1 / (i + 1); i++; }while (!(i != 1 && Math.Abs(a - oldvalue) < 0.0001)); // we can remove i!=1 if we know and hard code first default value return a; } 上添加VALUES关键字:

strInsert

答案 1 :(得分:0)

Dim userInput As String
userInput = TextBox1.Text 'an example of user input from a textbox
Dim MySQLStatement As String = "SELECT * FROM `your_table` WHERE your_column = '" & userInput & "';"

您可以将关键字值添加到查询中