473,769 Members | 5,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bind ListBox

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 = "myconnectionst ring..."
Dim SQL As String = "SELECT Town from Info group by Town;"
Dim myConnection As New SqlConnection(C onnStr)
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim MyAdapter As New SqlDataAdapter
Dim mydataset As New DataSet

MyAdapter.Selec tCommand = myCommand
myConnection.Op en()
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(mydata set.Tables("Tow n"))

LB1.DataSource = mydataset
LB1.DataBind()
myConnection.Cl ose()

On the LB1.Datasource line :
if i use "= mydataset" i receive only system.data.dat arowview for all the
item in my listbox.
if i use "= mydataset.LbVie w .. same thing
if i use "= mydataset.conta iner ... my listbox is empty, or fill with empty
string

Did someone have any idea what is wrong with my code ?

Thank you
Nov 20 '05 #1
1 3264
Hi,

LB1.DataSource = Lbview or LB1.Datasource = mydataset.table s("Town")
LB1.Displaymemb er = "Town"

Ken
----------------
"Andre" <lo*****@cablev ision.qc.ca> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
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 = "myconnectionst ring..."
Dim SQL As String = "SELECT Town from Info group by Town;"
Dim myConnection As New SqlConnection(C onnStr)
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim MyAdapter As New SqlDataAdapter
Dim mydataset As New DataSet

MyAdapter.Selec tCommand = myCommand
myConnection.Op en()
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(mydata set.Tables("Tow n"))

LB1.DataSource = mydataset
LB1.DataBind()
myConnection.Cl ose()

On the LB1.Datasource line :
if i use "= mydataset" i receive only system.data.dat arowview for all the
item in my listbox.
if i use "= mydataset.LbVie w .. same thing
if i use "= mydataset.conta iner ... my listbox is empty, or fill with
empty
string

Did someone have any idea what is wrong with my code ?

Thank you

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
12920
by: Alpha | last post by:
I have a listbox with datasource from a dataview. When a user selects a different item in a combobox then I need to refresh the listbox to the appropriate listing based on that combobox's selected value which is included in the listbox's filtering statement. Is the only way to do this is to dispose the dataview and then create a new one and then bind it to the listbox? Is there a better way than this? Thanks, Alpha
2
1968
by: Alpha | last post by:
I have a window application. On one of the form, there is a listbox and a few combox. The lstSchItem has a dataview as a datasource. The comboxes are bind to its selected value but through the dataset table. Now when I change the selection in the lstSchItem the comboxes are staying the same and not reflecting the changes. I tried changing the binding to the dataview.table but the comboxes are still not changing to reflect the...
0
1925
by: VbScripter | last post by:
In the code below, I have an editItemTemplate that will have to have a long list of ip's bound to it. The problem is that the lisbox is not seen by asp.net until after the datalist containing it is exposed. Is there a way to bind the ddl inside of an already databound templated column? Thanks , of course Michael
1
9259
by: john wright | last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I am including the code for the dictionary object. Here is the error I am getting: "System.Exception: Complex DataBinding accepts as a data source either an IList or an IListSource at System.Windows.Forms.ListControl.set_DataSource(Object value)
1
11305
by: Nicholas Shewmaker | last post by:
(I apologize if this posts twice. My AVG is being fussy.) From what I've read, MouseWheel is a very tricky event. I have replaced my Python tcl84.dll and tk84.dll files with those in the ActiveTcl distribution to fix the crashes caused by the event. Then, I managed to see that my test script (see code below) was registering the event by printing the delta value (+/- 120). ----------------- from Tkinter import *
1
4297
by: Patrik Zdarsa | last post by:
Hi, I'm try VS 2005 and need UPDATE database record in viewform, all working when every filed is type TextBox (html INPUT) but I need change one TextBox to Listbox or dropdownlist and read data from another table and store it in table1 in parameter "stav". Load data to ListBox is not problem but when I try update record there is error "stav is null", is any way how to bind listbox or dropdownlist. Code: <UpdateParameters>
2
1319
by: Juliano.net | last post by:
Can I bind an object of a class to a ListBox?
1
1536
by: MariaKhan | last post by:
?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ??? ?? bind DataSet with listbox ???
5
4756
by: jrobbins | last post by:
public IEnumerable<AuthorizationObjectClass> GetEmployeeNoAuthorizations(SqlInt32 PersonnelNumber) { DataSet ds; AuthorizationObjectClass auth = new AuthorizationObjectClass(); try { //EmployeeObjectClass Emp = new EmployeeObjectClass(); Emp.PersonnelNumber = PersonnelNumber; ds = data.GetNotSelectedAuthorizations(Emp); ...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7393
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.