Relating combo boxes

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2009
Posts: 20
Reputation: Manak is an unknown quantity at this point 
Solved Threads: 0
Manak Manak is offline Offline
Newbie Poster

Relating combo boxes

 
0
  #1
Jun 19th, 2009
Can nyone tell me how to relatr combo boxes????
i hv used this code bt this is throwing exception ......ny help would be appreciated .I hv jst started wworking on c#


i hv used the following code nd i hv populated the cmbschoolcode in loading of my form
  1. private void cmbSchCode_SelectedIndexChanged(object sender, EventArgs e)
  2. {
  3.  
  4. String connectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
  5.  
  6.  
  7. DataTable dt = new DataTable();
  8. string Query = String.Format(@"SELECT RegNo FROM Student WHERE SchoolCode ={0} ", cmbSchCode.Text);
  9. OleDbDataAdapter adapter = new OleDbDataAdapter(Query,connectionString);
  10.  
  11. adapter.Fill(dt);
  12.  
  13.  
  14.  
  15. foreach (DataRow dr in dt.Rows)
  16. {
  17. cmbStudent.Items.Add(dr[0].ToString());
  18. }
  19.  
  20.  
  21. }
its saying no value given to one or more parameters .
Last edited by Tekmaven; Jun 19th, 2009 at 3:14 am. Reason: Code Tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Relating combo boxes

 
0
  #2
Jun 19th, 2009
i think it requires ' ' around {0} to distinguish it from an SQL variable
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 20
Reputation: Manak is an unknown quantity at this point 
Solved Threads: 0
Manak Manak is offline Offline
Newbie Poster

Re: Relating combo boxes

 
0
  #3
Jun 19th, 2009
Originally Posted by serkan sendur View Post
i think it requires ' ' around {0} to distinguish it from an SQL variable

thanx mahn it really worked bt still one problem is dre that the value from student combo box is not going in the database.....
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Relating combo boxes

 
0
  #4
Jun 19th, 2009
yes but your query is a select query, to insert something into database you should run insert query which i dont see in your code.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 20
Reputation: Manak is an unknown quantity at this point 
Solved Threads: 0
Manak Manak is offline Offline
Newbie Poster

Re: Relating combo boxes

 
0
  #5
Jun 19th, 2009
Originally Posted by serkan sendur View Post
yes but your query is a select query, to insert something into database you should run insert query which i dont see in your code.

i hv inserted the insert query after my code but is shows exception that it will create duplicate values.i hv also tried the update query bt it also doen'nt work.....
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 20
Reputation: Manak is an unknown quantity at this point 
Solved Threads: 0
Manak Manak is offline Offline
Newbie Poster

Re: Relating combo boxes

 
0
  #6
Jun 19th, 2009
I hv inserted the insert query at the press of save button .....
every thing else is working but the value of student combo box is not going in the database.....plz nyone help meee
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 20
Reputation: Manak is an unknown quantity at this point 
Solved Threads: 0
Manak Manak is offline Offline
Newbie Poster

Re: Relating combo boxes

 
0
  #7
Jun 19th, 2009
leave it it is solved there was some problem in my query..
thank you very much for helping me...I am really grateful to you..
Could you help me on the other thread i am having another problem in my code...I would be really gratefull to you....
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC