Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2004, 08:54 PM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default binding combobox to sqlreader?

hi guys can i bind my combo box into sqlreader, if yes how?

 
Old October 12th, 2004, 11:34 PM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

       // populate a SqlDataReader object
        SqlDataReader objReader = objCommand.ExecuteReader();

        // set the source of the "starwars" datagrid
         DataGrid.DataSource = objReader;

         // bind the data to the grid
         DataGrid.DataBind();
         objReader.Close();

The above three lines can be used to bind.



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old October 13th, 2004, 12:27 AM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how bour in combo box is it possible to bind it in sqldatareader?

 
Old October 13th, 2004, 05:25 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try the same with Combo, also set DisplayMember and ValueMember property.



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old October 13th, 2004, 07:42 PM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi pradeep,

niway i find ur website cool,
Im using the code in Microsoft Application Data block for net Code
heres the code
 dr = SqlHelper.ExecuteReader(connection, "invoice2")
                    Me.ComboBox1.DataSource = dr
                    Me.ComboBox1.DisplayMember = "DOCNO"
                     Me.ComboBox1.ValueMember = "TRNO"
heres the error code
complex databinding accepts as a datasource either ilist or ilist source


 
Old October 14th, 2004, 09:47 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry drachx it seems we cannot bind DataReader directly to the comboBox, I am really sorry for this. But you can directly add all the values from the DataReader to the comboBox like below

while(reader.Read())
{
  comboBox1.add(reader["column"].ToString());
}

Thanks!



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old October 14th, 2004, 07:10 PM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok,tnx niway :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding ComboBox inside ListView problem gunnjamie Windows Presentation Foundation 1 July 17th, 2008 02:13 PM
Binding a comboBox to update a listView Amethyst1984 VB How-To 2 February 28th, 2006 03:07 PM
Issue Binding to ComboBox. lam_lvl VB.NET 2002/2003 Basics 1 February 22nd, 2006 09:38 PM
data binding a combobox ozPATT Excel VBA 1 November 16th, 2005 08:17 AM
ComboBox Data Binding bmains VB.NET 0 October 5th, 2004 02:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.