locked
Select statement doesnt bring data after (-) RRS feed

  • Question

  • User-1305858305 posted

    Hello,

    Trying to retrieve data from db. 

     cmd.CommandText = "SELECT [TopicName] FROM [Topics] where TopicName like '%' + @SearchText + '%' ";
                    cmd.Parameters.AddWithValue("@SearchText", prefix);
                    cmd.Connection = conn;
                    conn.Open();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            topics.Add(sdr["TopicName"].ToString());
                        }
                    }

    But if column contain dashes doesnt display after dashes. 
    How can I achieve this?

    Monday, April 25, 2016 2:46 PM

Answers

  • User-1305858305 posted

    codes retrieving good. It was my fault

     label: item.split('-')[0],
     val: item.split('-')[1]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 25, 2016 3:57 PM