“ORA-00936:缺少表达”

时间:2017-03-18 10:10:11

标签: c#

我在这个cmd.ExecuteNonQuery()中收到“ORA-00936:缺少表达式”的错误消息;我觉得这将是非常明显的事情!任何帮助都会很棒

private void button2_Click(object sender, EventArgs e)
{         
        string oradb = "Data Source=(DESCRIPTION="
      + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.103)(PORT=1521)))"
      + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)));"
      + "User Id=scott;Password=tiger;";
        OracleConnection conn = new OracleConnection(oradb);
        OracleCommand cmd = new OracleCommand("select empno,FNAME,LNAME,JOBID,ADDRESS from employee", conn);
        OracleDataAdapter da = new OracleDataAdapter(cmd);
        conn.Open();
        OracleDataReader read = cmd.ExecuteReader();
        while (read.Read())
                {
        REA rea = new REA();
       Int64 vempno = read.GetInt64(0);
       String  fnameValue = read.GetString(0);
       String lnameValue = read.GetString(1);
       String afterConcatfname = rea.Encrypt(fnameValue, rea.GenerateKey());
       String afterConcatlname = rea.Encrypt(lnameValue, rea.GenerateKey());           
      cmd.CommandText = "update employee set fname=:fname, lname =:lname where empno=:empno";               
      OracleParameter fname = new OracleParameter("fname", afterConcatfname);
      OracleParameter lname = new OracleParameter("lname", afterConcatlname);
      OracleParameter empno = new OracleParameter("empno", vempno);
      cmd.Parameters.Add(fname);
      cmd.Parameters.Add(lname);
      cmd.Parameters.Add(empno);
      cmd.Prepare();
      MessageBox.Show(cmd.CommandText);
      cmd.ExecuteNonQuery();
      cmd.Dispose();
      conn.Close();
      MessageBox.Show("User updated!");
      DataTable t = new DataTable();
      da.Fill(t);
     dataGridView1.DataSource = t;
}                

0 个答案:

没有答案