473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do you fill a listbox with a dataset object or tableadapters?

Lokean
71
I have taken over a project where a listbox is to be filled with values from a dataset object that has three columns through it's tableadapter

Prod_ID Prod_Decscrption ON_Hand

I've tested the table adapter, and it does return values.

But I can not figure out how to populate the listbox on my form,


I'm sure it's something simple, but I'm not seeing it.
Apr 17 '07 #1
3 4161
RedSon
5,000 Expert 4TB
I think you need a datagrid control. Checkout the links to popular sections of MSDN located at the top of this forum.
Apr 17 '07 #2
Lokean
71
I think you need a datagrid control. Checkout the links to popular sections of MSDN located at the top of this forum.

I solved it, but for those in our studio audience....

Here's what I did.



Dim r_datarow as new DataRow
Dim t_DataTable As New MyApp.eDataSet.X _CODE_LOOKUPDataTable()
Dim tf_TableFill As New MyApp.eDataSetTableAdapters.X_CODE_LOOKUPTableAdap ter()

For Each r_datarow In t_DataTable
lst_X.Items.Add(r_datarow.Item("X_CODE_TEXT"))
Next
Apr 17 '07 #3
klaydze
30
I have taken over a project where a listbox is to be filled with values from a dataset object that has three columns through it's tableadapter

Prod_ID Prod_Decscrption ON_Hand

I've tested the table adapter, and it does return values.

But I can not figure out how to populate the listbox on my form,


I'm sure it's something simple, but I'm not seeing it.
Dim objdataadapter As New SqlDataAdapter
Dim objcommand As New SqlCommand
Dim objdatatable As New DataTable
Dim objdataset As New DataSet
Dim objconn As New SqlConnection
Dim nrow As Integer

Dim strselect As String


strselect = "Select * from table1"
objconn = New SqlConnection("Server=localhost; DataBase=yourdbase; User ID=sa; pwd=")

objdataadapter.SelectCommand = New SqlCommand(strselect, objconn)
objdataadapter.Fill(objdataset)

objdatatable = objdataset.Tables(0)

For nrow = 0 To objdatatable.Rows.Count - 1
ListBox1.Items.Add(objdatatable.Rows(nrow).Item("y our field"))

Next
Apr 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: mathieu cupryk | last post by:
I have problems with listboxes in the webform2.cs, the textboxes are working well when I do a click on next. I am missing something. It works with the textboxes. Here is the file: using System;...
3
by: Hrvoje Voda | last post by:
How to Fill a listbox with data from database? Hrcko
0
by: Abra | last post by:
Is it possible to fill a ADO.NET dataset incrementally ? (I mean to call the DataAdapter Fill() method several times, as I did not found a Add() method) I would like to call in a background thread...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
3
by: Rich | last post by:
Hello, I am just starting out with VB.net. I need to fill a listbox with data from an MS Access mdb file. What I tried was to create/add an ole connection object, then added an ole adapter...
5
by: Dave | last post by:
Hi All, I have a windows form that contains 2 listboxes and 2 buttons. The listbox on the right is populated by a database routine (This is the easy part). The listbox on the left is populated...
3
by: Jon B | last post by:
Hi There! I'm looking into Strongly Typed DataSets in the .NET Framework. I know it can generated strongly typed tables as objects and column names as properties. However, one thing that I...
0
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of...
2
by: rrflore2 | last post by:
Ok. I'm writing and deleting to an xml file using a dataset. I have a function in my codebehind page that binds a listbox to the dataset that performs the writes/deletes. Everything seems to be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.