Click here to Skip to main content
16,013,918 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
1 - i make text box with auto complicate extended
2- i pot my connection string

"

<connectionStrings>
        <add name="conn" connectionString="Data Source=.;Initial Catalog=Tranning;Integrated Security=True" providerName="System.Data.SqlClient"/>
        <add name="tempdbConn" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\tempdb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>

"
and i make method


[System.Web.Script.Services.ScriptMethod()]
        [System.Web.Services.WebMethod]
        public static List<string> SearchCustomers(string prefixText, int count)
        {
            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager
                        .ConnectionStrings["conn"].ConnectionString;
                using (SqlCommand cmd = new SqlCommand())
                {
                    //cmd.CommandText = "select ContactName from Customers where " +
                    //"ContactName like @SearchText + '%'";
                    cmd.CommandText = "select No_Trainee from Annual_Plan where No_Trainee like @SearchText + '%' ";
                    cmd.Parameters.AddWithValue("@SearchText", prefixText);
                    cmd.Connection = conn;
                    conn.Open();
                    List<string> customers = new List<string>();
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            customers.Add(sdr["No_Trainee"].ToString());
                        }
                    }
                    conn.Close();
                    return customers;
                }
            }
        }


and still my text Box not get values from database


Please need help !!!
Posted
Comments
thatraja 9-Oct-13 5:43am    
where's the text & its related code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900