A
Andre
Hi,
I try to bind my dataset to a listbox, but i can't find a way to make it
work. I'm lost ;o)
Dim ConnStr As String = "myconnectionstring..."
Dim SQL As String = "SELECT Town from Info group by Town;"
Dim myConnection As New SqlConnection(ConnStr)
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim MyAdapter As New SqlDataAdapter
Dim mydataset As New DataSet
MyAdapter.SelectCommand = myCommand
myConnection.Open()
MyAdapter.Fill(mydataset) --------- or MyAdapter.Fill(mydataset, "Town")
--- this line is for a test, don't know if i need to use it -------
Dim LbView As New DataView(mydataset.Tables("Town"))
LB1.DataSource = mydataset
LB1.DataBind()
myConnection.Close()
On the LB1.Datasource line :
if i use "= mydataset" i receive only system.data.datarowview for all the
item in my listbox.
if i use "= mydataset.LbView .. same thing
if i use "= mydataset.container ... my listbox is empty, or fill with empty
string
Did someone have any idea what is wrong with my code ?
Thank you
I try to bind my dataset to a listbox, but i can't find a way to make it
work. I'm lost ;o)
Dim ConnStr As String = "myconnectionstring..."
Dim SQL As String = "SELECT Town from Info group by Town;"
Dim myConnection As New SqlConnection(ConnStr)
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim MyAdapter As New SqlDataAdapter
Dim mydataset As New DataSet
MyAdapter.SelectCommand = myCommand
myConnection.Open()
MyAdapter.Fill(mydataset) --------- or MyAdapter.Fill(mydataset, "Town")
--- this line is for a test, don't know if i need to use it -------
Dim LbView As New DataView(mydataset.Tables("Town"))
LB1.DataSource = mydataset
LB1.DataBind()
myConnection.Close()
On the LB1.Datasource line :
if i use "= mydataset" i receive only system.data.datarowview for all the
item in my listbox.
if i use "= mydataset.LbView .. same thing
if i use "= mydataset.container ... my listbox is empty, or fill with empty
string
Did someone have any idea what is wrong with my code ?
Thank you