2016-03-29 97 views
0

一部の体は私を助けます。私はどこでエラーが発生するのかわからないので、私はこのエラーを修正できません。 ORA-00926:cmd.ExecuteNonQuery();の後にC#でVALUESキーワードが見つかりませんでした。ORA-00926: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(); 

答えて

1

エラーメッセージが示すように、あなたがテーブルのすべての列名を指定した後、あなたのstrInsertVALUESキーワードを追加しよう:

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

あなたがにキーワード値を追加するforgorあなたのお問い合わせ