interactive | editorial | code | resource 
Demonstrations > Dictionary lookup
 

Dictionary lookup

Word dictionary

This dictionary of English words contains around 140,000 records. Clearly, loading this volume of data into a conventional HTML drop-down would be impractical.
Type in the box below, and DbCombo will autocomplete your input:

    

The code...

And the code required to produce this functionality? - take a look:

<DbCombo:DbCombo Runat=server ID="Dbcombo1" DropDownRows="20" />

<script runat=server>
    [Cambro.Web.DbCombo.ResultsMethod(true)]
    public static object DbComboMethod(
        Cambro.Web.DbCombo.ServerMethodArgs args)
    {
    
        SqlConnection conn = new SqlConnection("your-connection-string");
        
        SqlCommand myCommand = new SqlCommand(@"
            SELECT TOP "+args.Top+@" 
                Word, 
                RTRIM(Word) as DbComboText, 
                RTRIM(word) as DbComboValue 
            FROM tWords 
            WHERE Word LIKE @Query 
            ORDER BY Word", conn);
            
        myCommand.Parameters.Add("@Query", args.Query+"%");
        
        myCommand.Connection.Open();
        
        return myCommand.ExecuteReader(CommandBehavior.CloseConnection);
    }
</script>

 
Demonstrations > Dictionary lookup