supersnoop Posted November 25, 2003 Posted November 25, 2003 Please can someone tell me how to populate a dropdownlist from two sql statements. 'get programs MyCommand = New SqlDataAdapter("select distinct intProgramID,strProgCode from programs order by strProgCode", MyConnection) DS = New DataSet MyCommand.Fill(DS, "Programs") this code works! but now I want divisions in the same dropdownlist 'get divisions MyCommand = New SqlDataAdapter("select distinct intdiv,strdiv from divisions order by strdiv", MyConnection) MyCommand.Fill(DS, "Divisions") Now I only see divisions...my programs got over ridden. Perhaps I should add both results into an array and bind the array? How do I do that? Or is there a better way? Quote
Moderators Robby Posted November 25, 2003 Moderators Posted November 25, 2003 The array is one way, but it order to that you will probably use a DataReader. Since you'll use a DataReader eitherway, then simply myDropdownItems.Add() while looping the DataReader and skip the databinding methid. Quote Visit...Bassic Software
supersnoop Posted November 25, 2003 Author Posted November 25, 2003 Thanks Robby....I'm a beginner so what you said is a little confusing. Any chance you could quickly show me how to populate a datareader and then loop thru it putting results into dropdownlist? Thanks :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.