Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. checkedListBox binding with DataReader.

checkedListBox binding with DataReader.

Scheduled Pinned Locked Moved C#
helpwpfwcftutorial
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sea
    wrote on last edited by
    #1

    I’m writing ADO program connected to MS access with DataReader. Need to bind a checkedListBox to a table. This is what I wrote:

    	public void BindCheckedListBox(CheckedListBox BooksCheckedListBox)
    	{
    		ArrayList books = new ArrayList();
    		string sqlBindList = "SELECT BookName " +
    			"FROM books "+
    			"ORDER BY BookName ";
    
    		OleDbCommand cmdShowStock = new OleDbCommand();
    		cmdShowStock.Connection = cnShop;
    		cmdShowStock.CommandType = CommandType.Text;
    		cmdShowStock.CommandText = sqlBindList;
    		cnShop.Open();
    		OleDbDataReader reader = cmdShowStock.ExecuteReader();
    		BooksCheckedListBox.DataSource = reader;
    	}
    

    When run it with debbuger I get an exception: “Complex DataBinding accepts as a data source either an IList or an IListSource”. Trying to figure out how to work with those interfaces I got nowhere :(. Please help me clear up this issue! TIA, sea#

    J 1 Reply Last reply
    0
    • S sea

      I’m writing ADO program connected to MS access with DataReader. Need to bind a checkedListBox to a table. This is what I wrote:

      	public void BindCheckedListBox(CheckedListBox BooksCheckedListBox)
      	{
      		ArrayList books = new ArrayList();
      		string sqlBindList = "SELECT BookName " +
      			"FROM books "+
      			"ORDER BY BookName ";
      
      		OleDbCommand cmdShowStock = new OleDbCommand();
      		cmdShowStock.Connection = cnShop;
      		cmdShowStock.CommandType = CommandType.Text;
      		cmdShowStock.CommandText = sqlBindList;
      		cnShop.Open();
      		OleDbDataReader reader = cmdShowStock.ExecuteReader();
      		BooksCheckedListBox.DataSource = reader;
      	}
      

      When run it with debbuger I get an exception: “Complex DataBinding accepts as a data source either an IList or an IListSource”. Trying to figure out how to work with those interfaces I got nowhere :(. Please help me clear up this issue! TIA, sea#

      J Offline
      J Offline
      jdkulkarni
      wrote on last edited by
      #2

      Hi, You can only assign those objects as a datasource which implements ILIst or IListSource interface e.g. DataSet, Array. So you can not assign DataReader as a datasource to a listbox or combobox. Jayant Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups