Question

I've faced with a strange problem in ASP.net/SQL Server and really can not find out what is the problem. I have a AutoCompleteExtender that finds out the predicted results from a web service. All the times it was working great with both english and non-english characters until I became forced to change the collation of the SQL Server 2008 database that was feeding the webservice.

Nothing changed but the collation of this database and column type which was changed from Nvarchar to Varchar. SQL server shows results correct while executing the query but:

The problem is that when typing in english in autocompleteextender textbox it responds immediately but when I enter a non-english word there, i should PRESS the BACKSPACE key to delete the last character so that it respond. My database collation is SQL_Latin1_General_CP1256_CI_AS.

I can't realize why this strange behaviour is exposed while entering non-english characters.

Here is the Web service code attached to my ajax autocompleteextender:

[WebMethod(EnableSession = true)]
    [System.Web.Script.Services.ScriptMethod]
    public string[] GetCompletionListByVT(string prefixText, int count)
    {
        List<string> returnData = new List<string>();
        try
        {
            string connStr = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
            SqlConnection objconnection = new SqlConnection(@connStr);
            string strsql = "SELECT TOP 10 CompanyName FROM ViewAutoCompleteWSFeed WHERE (CompanyName LIKE '%" + prefixText+"" + "%');";
            objconnection.Open();          
             // strsql = "SELECT TOP 10 CompanyName FROM ViewAutoCompleteWSFeed WHERE (CompanyName LIKE '%" + prefixText + "%' OR Business_Landline_Phone_1 LIKE '%" + prefixText + "%' OR Business_Landline_Phone_2 LIKE '%" + prefixText + "%' OR MobileNumb1 LIKE '%" + prefixText + "%' OR MobileNumb2 LIKE '%" + prefixText + "%' OR EmailAddress LIKE '%" + prefixText + "%' OR Business_Address LIKE '%" + prefixText + "%' OR htCompanySN LIKE '%" + prefixText + "%' OR htCompanyNo LIKE '%" + prefixText + "%' OR Notes LIKE '%" + prefixText + "%');";
            SqlCommand objcommand = new SqlCommand(strsql, objconnection);
            SqlDataReader dr = objcommand.ExecuteReader();
            while (dr.Read())
            {
                returnData.Add(dr["CompanyName"].ToString());
            }

            objconnection.Close();
            return returnData.ToArray();
        }
        catch (Exception ex)
        {
            returnData.Add(prefixText);
        }

        return returnData.ToArray();

    }
Was it helpful?

Solution

The solution is that you delete the temporary folder for your website under the .net framework folder on your windows folder. The next time you compile and build your website the problem disappears.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top