Predictive search isn't working?

This is aspx file code.

<html xmlns="">
<head id="Head1" runat="server">
<title>AutoComplete Box with jQuery</title>
<link href="" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script> 
<script type="text/javascript">
    $(document).ready(function () {
    function SearchText() {
            source: function (request, response) {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Default.aspx/GetAutoCompleteData",
                    data: "{'username':'" + document.getElementById('txtSearch').value + "'}",
                    dataType: "json",
                    success: function (data) {
                    error: function (result) {
<form id="form1" runat="server">
<div class="demo"></div>
<div class="ui-widget">
<label for="tbAuto">Enter UserName: </label>
<input type="text" id="txtSearch" class="autosuggest" />

This is .cs file code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.Services;

public partial class demo : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

     public static string getconnectionstring()
        return System.Configuration.ConfigurationManager.ConnectionStrings["crudconnection"].ConnectionString;
    public static List<string> GetAutoCompleteData(string username)
        List<string> result = new List<string>();
        SqlConnection con = new SqlConnection(getconnectionstring();

            using (SqlCommand cmd = new SqlCommand("select DISTINCT username from crudtable where username LIKE '%'+@SearchText+'%'", con))
                cmd.Parameters.AddWithValue("@SearchText", username);
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                return result;


The database "crud" has "crudtable" with columns (username,firstname,lastname,address,id).When i type anything in the textbox and pres button the ,Search isn't working. Everything seems to be right but don't know where is the error.

Help friends.



Problem lies in this line of code

cmd.Parameters.AddWithValue("@SearchText", username);

Do not add @ in the parameter name. Use

cmd.Parameters.AddWithValue("SearchText", username);

Second add a breakpoint and check if your code is hit by ajax call or not.

Need Your Help

Overriding public virtual functions with private functions in C++

c++ override access-control virtual-functions

Is there is any reason to make the permissions on an overridden C++ virtual function different from the base class? Is there any danger in doing so?