dataadapter and component

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm creating a component that contains a function. This function is to return
a data set of state values (AL,IL,TN,CA,...). I'm new to dataadapters this is
my first, but something just doesn't seem right.

the function return a dataset, but do it need to define a dataset in the
body of the function as well as in the calling routine?
2. can i bind this dataset to two different drop down lists?

here is my function.

Public Class states
Inherits System.ComponentModel.Component
Public Function GetStates() As DataSet
Dim ddlStates As DataSet = New DataSet

Dim strcon As String = "DSN=SE;"
Dim conSE As New OdbcConnection(strcon)
Dim strSQL As String = "select staStateName, staLongName from sta
where 1=1 order by staStateName"
Dim daStates As OdbcDataAdapter
daStates = New OdbcDataAdapter(strSQL, conSE)
'Fill dataset
conSE.Open()
daStates.Fill(ddlStates, "states")
conSE.Close()
Return ddlStates
End Function
 
OK, Kurt, so what doesn't seem right? Is this code working or not? The code,
as it is, looks fine.

As far as binding to two different dropdown lists, I'm not 100% sure. I work
with WinForms and you have to use separate DataSources for ComboBoxes there.
I'm not sure if the same applies with a WebForm's DropDownList.

~~Bonnie
 
thank's for the response,
It seems the same appilies here. There is a way around it , but that would
mean adding the items via a loop w/o binding.
thank you
kes
 
Kurt,

But, you don't have to get the same DataSet from your database two tiimes
.... you can get it once, and then for your second instance of it (for you
second dropdownlist), you can just copy it.

~~Bonnie
 
Back
Top