我尝试使用Orcale命令运行此更新方法,但我不断收到错误“ sql命令未正确结束”

时间:2019-04-14 12:42:19

标签: c# asp.net oracle

public void SaveEdits()
        {
                    string SQL = "UPDATE SURVEY_CAMPAIGN SET OUTGOING_VDN =" + txtOutgoing.Value + "AND LANG_CD =" + txtlang.Value + "AND ANNOUNCEMENT_FOLDER =" + txtAnnouc.Value + "AND EXCEEDED_AUDIO =" + txtExceed.Value + "AND VALID_ENTRY_AUDIO =" + txtExit.Value +
                   " WHERE  CAMPAIGN_ID =" + CampignsDRP.SelectedValue;
                    try
                    {
                        using (OracleConnection conn = SingleConnection.Instance.ActiveConn)
                        {
                            conn.Open();
                            OracleCommand cmd = conn.CreateCommand();
                            OracleDataAdapter dataAdapter = new OracleDataAdapter(SQL, conn);
                            System.Data.DataSet db = new System.Data.DataSet();

                            cmd.CommandType = CommandType.Text;
                            cmd.CommandText = SQL;
                            int result = cmd.ExecuteNonQuery();
                            dataAdapter.Fill(db, "Campaign");

                            cmd.Dispose();
                            conn.Close();
                        }

                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "UpdateCompleted()", true);
                    }
                    catch (Exception ex)
                    {

                        string error = ex.Message;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "ShowError('" + error + "')", true);
                        LogUtil.Debug("Page Campaign Update Exception Occured " + ex.Message);


                    }

        }

1 个答案:

答案 0 :(得分:0)

string SQL = "UPDATE SURVEY_CAMPAIGN SET OUTGOING_VDN = @OUTGOING_VDN,  LANG_CD = @LANG_CD, ANNOUNCEMENT_FOLDER = @ANNOUNCEMENT_FOLDER, EXCEEDED_AUDIO = @EXCEEDED_AUDIO, VALID_ENTRY_AUDIO = @VALID_ENTRY_AUDIO WHERE CAMPAIGN_ID = @CAMPAIGN_ID"  ;

//Now put this parameters before int result = cmd.ExecuteNonQuery();

cmd.Parameters.AddWithValue("@OUTGOING_VDN", txtOutgoing.Text);
cmd.Parameters.AddWithValue("@LANG_CD", txtlang.Text);
cmd.Parameters.AddWithValue("@ANNOUNCEMENT_FOLDER", 
txtAnnouc.Text);
cmd.Parameters.AddWithValue("@EXCEEDED_AUDIO", txtExceed.Text);
cmd.Parameters.AddWithValue("@VALID_ENTRY_AUDIO", txtExit.Text);
cmd.Parameters.AddWithValue("@CAMPAIGN_ID", CampignsDRP.SelectedValue);