Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT InvoiceDetails.ItemId, Item_master.item_code
FROM (InvoiceDetails INNER JOIN [Transaction] ON InvoiceDetails.Trans_id = Transaction.Trans_id) INNER JOIN Item_master ON InvoiceDetails.ItemId = Item_master.Item_id where (((Transaction.invoice_no)='" + txt_invoice.Text + "'))

I use this query for getting special data.

I want to display ItemCode in ComboBox.
Posted
v3
Comments
IpsitaMishra 31-Jul-13 6:32am    
Where are you getting the problem?
Ashutosh_jha 31-Jul-13 6:37am    
how i populate combobox using this query.
Maciej Los 31-Jul-13 7:02am    
What you mean? What have you done till now? Where are you stuck?
Ashutosh_jha 31-Jul-13 7:06am    
I want to populate Combobox with ItemCode. getting ItemCode by searching via query.
[no name] 31-Jul-13 7:17am    
Okay so go ahead and do that. "I want" and not a question or description of a problem. Where is the code that you have written to populate the combobox? What is the problem with your code?

Refer - Fill Combobox from database[^].
It has a code snippet explaining how to Bind the ComboBox.

So,

  • Create a Connection
  • Get the data by query
  • Fill to a DataSet
  • Assign appropriate DataSource, DisplayMember and ValueMember for the ComboBox
 
Share this answer
 
Comments
IpsitaMishra 31-Jul-13 7:47am    
Nice Explanation TaditD :)
Thanks a lot Ipsita... :)
Use ADO.Net disconnected mode for this.

1) create databse connection object
2) create dataadapter object and dataset object.
3) create sql command object and perform the dataadapter's Fill method for dataset object.
4) Now you have data in dataset's table.
5) bind the combo box's data source property to this table.
C#
this.comboBox1.DataSource = dataSource;
this.comboBox1.DisplayMember = "Name";
this.comboBox1.ValueMember = "Value";

// make it readonly
this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;




Please Mark as Answer if suffice your query.

Regards,
Dheeraj Gupta
 
Share this answer
 

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