Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All
I am currently working on C# windows application where I am using MS Access 2003 DB as back end I am trying to get filter data in combo box as example If I put 0 so it should show all 0 started data in the combo box but it doesn't and also under which event of the combo box it will come below I show Code

private void comboBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        
        {
            comboBox.Refresh();
            string str = "SELECT BookID FROM BookMaster WHERE BookID like '%" + comboBox.Text + "%'";
            OleDbCommand cmd = new OleDbCommand(str, conn);
            OleDbDataAdapter da = new OleDbDataAdapter();
            da.SelectCommand = cmd;
            DataTable dt = new DataTable();
            da.Fill(dt);           
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comboBox.Items.Add(dt.Rows[i]["BookID"]);
            }            
        }  

but it is not coming as expectation

Thanks & Regards
Indrajit Dasgupta
Posted
Updated 29-Jan-12 22:07pm
v2
Comments
Rajesh Anuhya 30-Jan-12 4:08am    
pre tags added
--RA

1 solution

Check your Query returns values, your DataSet is not empty..
Thanks
--RA
 
Share this answer
 
Comments
IndrajitDasgupat 30-Jan-12 4:14am    
Data table is not empty but it is not coming filter data which I mentioned above
Rajesh Anuhya 30-Jan-12 4:18am    
Any exception you are getting?
try like this
comboBox.Items.Add(dt.Rows[i]["BookID"].ToString());
--RA

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