Click here to Skip to main content
15,885,182 members
Articles / Web Development / HTML

Google Suggest like Dictionary

Rate me:
Please Sign up or sign in to vote.
4.87/5 (78 votes)
26 Dec 20043 min read 307.7K   3.2K   206  
An implementation of Google suggest using remote scripting.
<%@Page Language="C#"%>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<%@Import Namespace="System.Configuration"%>
<script runat="server">

    public void Page_Load(object sender,EventArgs args)
    {
		string keyword=Request["k"];
		if(keyword!=null && keyword.Trim()!="")
		{
			string sql="select top 10* from WordList where word like '"+keyword.Trim().Replace("'","''")+"%'";		
			SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
			conn.Open();
			DataTable dt=new DataTable();
			SqlCommand command=new SqlCommand(sql,conn);
			SqlDataAdapter adapter=new SqlDataAdapter(command);
			adapter.Fill(dt);
			conn.Close();
			
			foreach(DataRow row in dt.Rows)
			{
				string meaning=row["Meaning"].ToString();
				Response.Write("<strong>"+row["Word"].ToString()+"</strong> <i>"+row["Type"].ToString()+"</i>: "+meaning+"<br>");
			}
        }

		
    }

</script>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions