ORA-01756: quoted string not properly terminated

Last Reply on Nov 25, 2012 08:03 AM By Mudassar

Posted on Nov 25, 2012 08:02 AM

I am trying to retriev data from oracle data base for the first time using c# i am trying like this,.

and getting this error ORA-01756: quoted string not properly terminated

string oradb = "Data Source=(DESCRIPTION=" + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=100.3.1.14)(PORT=1521)))"
            + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=HI1)));" + "User Id=sam;Password=k123k;";
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
protected void Button1_Click(object sender, EventArgs e)
        {
          
            
            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
           string sql = "select PAT_NAME,PAT_ID,PHONE_NO from PAT_REG" + "where PATIENT_NO = " + TextBox1 +"'";
            OracleCommand cmd = new OracleCommand(sql, conn);
            cmd.CommandType = CommandType.Text;
            
            OracleDataReader dr = cmd.ExecuteReader(); <-- ORA-01756: quoted string not properly terminated
            dr.Read();
            TextBox2.Text = dr[0].ToString();
            TextBox3.Text = dr[1].ToString();
            TextBox4.Text = dr[2].ToString();

        }

 

Posted on Nov 25, 2012 08:03 AM

Try this

string sql = "select PAT_NAME,PAT_ID,PHONE_NO from PAT_REG where PATIENT_NO = '" + TextBox1 + "'";