locked
autoextender condition problem? RRS feed

  • Question

  • User-1089808927 posted

    I have one autoextender I want serach result come with the condition

    my code is

    [System.Web.Script.Services.ScriptMethod()]
            [System.Web.Services.WebMethod]
            public static List<string> GetCountries(string prefixText)
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from tbl_new_supplier where SupplierName like @Name+'%' and suypplierTypeID=3", con);
                cmd.Parameters.AddWithValue("@Name", prefixText);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                List<string> CountryNames = new List<string>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    CountryNames.Add(dt.Rows[i][1].ToString());
                }
                return CountryNames;
            }


    Thursday, October 17, 2013 1:18 AM

Answers

  • User-933407369 posted

    you can try the follow workaround:

     SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from tbl_new_supplier where SupplierName like '@Name%' and suypplierTypeID=3", con);
                cmd.Parameters.AddWithValue("@Name", prefixText);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 23, 2013 11:30 AM

All replies

  • User-1360095595 posted

    (string prefixText, int count). Try that. If you're still facing trouble maybe you can explain what trouble it is. 

    Thursday, October 17, 2013 2:38 AM
  • User-1089808927 posted

    I have two column name and type

    If  I type text in textbox the text should search across the condition in the sense

    in where condition both name and type should be satisfied.

    Thursday, October 17, 2013 2:46 AM
  • User-1360095595 posted

    Yes, I think it's clear what you're trying to do. What's not clear, at least to me, is exactly what trouble/problem you're having.

    Thursday, October 17, 2013 2:58 AM
  • User-1089808927 posted
    [System.Web.Script.Services.ScriptMethod()]
            [System.Web.Services.WebMethod]
            public static List<string> GetCountries(string prefixText)
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from tbl_new_supplier where SupplierName like @Name+'%' and suypplierTypeID=3", con);
                cmd.Parameters.AddWithValue("@Name", prefixText);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                List<string> CountryNames = new List<string>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    CountryNames.Add(dt.Rows[i][1].ToString());
                }
                return CountryNames;
            }

    above underline code "and suypplierTypeID=3"  is  not working

    Thursday, October 17, 2013 3:05 AM
  • User-1089808927 posted

    Any answer u get for this solutions

    Thursday, October 17, 2013 5:22 AM
  • User555306248 posted

    You can use SQL profiler to trace it out what exactly query is getting executed.

    Thursday, October 17, 2013 11:59 PM
  • User-1089808927 posted

    Y aits perfectly executed

    Friday, October 18, 2013 1:22 AM
  • User-933407369 posted

    you can try the follow workaround:

     SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
                con.Open();
                SqlCommand cmd = new SqlCommand("select * from tbl_new_supplier where SupplierName like '@Name%' and suypplierTypeID=3", con);
                cmd.Parameters.AddWithValue("@Name", prefixText);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 23, 2013 11:30 AM