SQL querry Combo Box Question

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 17
Reputation: blazted is an unknown quantity at this point 
Solved Threads: 0
blazted blazted is offline Offline
Newbie Poster

SQL querry Combo Box Question

 
0
  #1
Oct 23rd, 2007
I have a combobox that is populated by a SQL querry. Problem is the first item of the comboBox where normally the comboBox.text go is blank. You have to drop down the menu item for the items to appear. I want to comboBox to populated with the first item in the first row. I am currently populating my comboBox with the add property

  1.  
  2. while (oleDbDataReader1.Read() == true)
  3. {
  4. comboBox1.Items.add = oleDbDataReader1.GetString(0) ;
  5. }

This though is skipping the first field. How can I add the first result from the query to the first field in my comboBox?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: SQL querry Combo Box Question

 
0
  #2
Oct 23rd, 2007
I think if you changed the DropDownStyle from DropDown to DropDownList*
it may help you

*: from ComboBox control properties window
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: SQL querry Combo Box Question

 
0
  #3
Oct 23rd, 2007
you may also try after filling the ComboBox control to show the first index

  1. comboBox1.SelectedIndex = 0;
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 17
Reputation: blazted is an unknown quantity at this point 
Solved Threads: 0
blazted blazted is offline Offline
Newbie Poster

Re: SQL querry Combo Box Question

 
0
  #4
Oct 23rd, 2007
Thank you the selected Index worked fine.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 83
Reputation: Elmo_loves_you is an unknown quantity at this point 
Solved Threads: 0
Elmo_loves_you's Avatar
Elmo_loves_you Elmo_loves_you is offline Offline
Junior Poster in Training

Re: SQL querry Combo Box Question

 
0
  #5
Aug 20th, 2008
Hi

I have a tabbed control. Tab1 is for adding new customer details and Tab2 is for searching for existing customers (from a comboBox) and then adding additional information for that customer.

How can I make the results of a stored procedure be automatically displayed in the comboBox(DropDownList) as soon as the user clicks on that tab?

Thanks

Elmo
Michelle (Junior Developer)
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 83
Reputation: Elmo_loves_you is an unknown quantity at this point 
Solved Threads: 0
Elmo_loves_you's Avatar
Elmo_loves_you Elmo_loves_you is offline Offline
Junior Poster in Training

Re: SQL querry Combo Box Question

 
0
  #6
Aug 20th, 2008
Never mind, Sorted

Originally Posted by Elmo_loves_you View Post
Hi

I have a tabbed control. Tab1 is for adding new customer details and Tab2 is for searching for existing customers (from a comboBox) and then adding additional information for that customer.

How can I make the results of a stored procedure be automatically displayed in the comboBox(DropDownList) as soon as the user clicks on that tab?

Thanks

Elmo
Michelle (Junior Developer)
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 4
Reputation: needhelp// is an unknown quantity at this point 
Solved Threads: 0
needhelp// needhelp// is offline Offline
Newbie Poster
 
0
  #7
33 Days Ago
can anyone say me how to insert the string of combo box into the table in oracle... from VB pls anyone help me with the code....
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: durgesh_niit is an unknown quantity at this point 
Solved Threads: 0
durgesh_niit durgesh_niit is offline Offline
Newbie Poster
 
0
  #8
32 Days Ago
sqldataReader dr = cmd.ExecuteReader();\\cmd is object of sql command
while(dr.Read())
{
comboBox1,Items.Add(dr[0].ToString());
}
con.Close();\\con is a object of sqlconnection
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: durgesh_niit is an unknown quantity at this point 
Solved Threads: 0
durgesh_niit durgesh_niit is offline Offline
Newbie Poster

sql

 
0
  #9
32 Days Ago
Originally Posted by Elmo_loves_you View Post
Hi

I have a tabbed control. Tab1 is for adding new customer details and Tab2 is for searching for existing customers (from a comboBox) and then adding additional information for that customer.

How can I make the results of a stored procedure be automatically displayed in the comboBox(DropDownList) as soon as the user clicks on that tab?

Thanks

Elmo
you are using sqldatareader or sql dataadapter
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 4
Reputation: needhelp// is an unknown quantity at this point 
Solved Threads: 0
needhelp// needhelp// is offline Offline
Newbie Poster
 
0
  #10
32 Days Ago
rs.Open "insert into traveldet values('" & Text1.Text & "' ,'" & saccdate.Text & "','" & sretdate.Text & "','" & stype.Text & "','" & smodel.Text & "','" & Combo1.Text & "','" & Combo2.Text & "',null,'" & snopass.Text & "')", conn, adOpenDynamic, adLockOptimistic, -1

thanks friends...
this code worked for me...
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC