Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • Moderators
Posted

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.

Visit...Bassic Software
Posted
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 :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...