Hi alhakimyyes,
First correct your data source property of OracleConnection then add DataBase property to specify the name of database you are using the select query.
Use parameterized query.
Refer below updated code.
C#
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetCompletionList(string prefixText, int count)
{
using (OracleConnection con = new OracleConnection("data source=localhost:1521\\orcl;DataBase=Northwind user id=alhakimy; password=alhakimyyes;"))
{
using (OracleCommand com = new OracleCommand())
{
com.CommandText = "select doc_no, doc_name from doctors where city_no = @CityNo and doc_name like '%' + @DocName + '%'";
com.Parameters.Add("@DocName", prefixText);
com.Parameters.Add("@CityNo", HttpContext.Current.Session["city_no"]);
com.Connection = con;
con.Open();
List<string> summ = new List<string>();
using (OracleDataReader sdr = com.ExecuteReader())
{
while (sdr.Read())
{
summ.Add(string.Format("{0}-{1}", sdr["DOC_NAME"], sdr["Doc_NO"]));
}
}
con.Close();
return summ;
}
}
}