473,408 Members | 2,113 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,408 software developers and data experts.

Binding a combo box

TS
I configured a data adapter and generated a dataset and wrote the code to
fill the dataset with data coming from an SQL database table when my form
loads. I also changed the DataSource of a combo box to point to the
dataset.tablename and changed the DisplayMemebr to point at a column. After
the form loads nothing is populated in the combo box? Is there something I'm
missing. Please help
--
TS
Nov 21 '05 #1
3 1003
Hi,

Here is an example.

Dim strConn As String

Dim strSQL As String

Dim ds As New DataSet

Dim da As OleDbDataAdapter

Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Categories", conn)

da.Fill(ds, "Categories")

ComboBox1.DataSource = ds.Tables("Categories")

ComboBox1.DisplayMember = "Description"

Ken

--------------------------

"TS" <TS@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
I configured a data adapter and generated a dataset and wrote the code to
fill the dataset with data coming from an SQL database table when my form
loads. I also changed the DataSource of a combo box to point to the
dataset.tablename and changed the DisplayMemebr to point at a column. After
the form loads nothing is populated in the combo box? Is there something I'm
missing. Please help
--
TS
Nov 21 '05 #2
TS,

Show a little piece of code, (first without the designer part).
(And please first pasted in a notebook and copied back to make it readable)

(I assume that you bind in the desiger and that you told in that wich
*datatable*, often is the wrong point taken to do that, so you can check
that first)

Cor
Nov 21 '05 #3
TS
Thanks for your reply. I tried the code you sent me and it generated the
following error message: "Unhandled Exception:
System.Data.OleDb.OleDbException: Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was done.

Here is the code:

Dim strConn As String

Dim strSQL As String

Dim SscIntake1 As New DataSet()

Dim da As OleDb.OleDbDataAdapter

Dim conn As OleDb.OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Persist Security Info=true;Integrated
Security=false;User ID=sa;Password=xxx;database=SSC;server=zzz;"

conn = New OleDb.OleDbConnection(strConn)

da = New OleDb.OleDbDataAdapter("Select * From qmf_cint", conn)

da.Fill(SscIntake1, "qmf_cint")

ComboBox1.DataSource = SscIntake1.Tables("qmf_cint")

ComboBox1.DisplayMember = "Last_Name"

"Ken Tucker [MVP]" wrote:
Hi,

Here is an example.

Dim strConn As String

Dim strSQL As String

Dim ds As New DataSet

Dim da As OleDbDataAdapter

Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Categories", conn)

da.Fill(ds, "Categories")

ComboBox1.DataSource = ds.Tables("Categories")

ComboBox1.DisplayMember = "Description"

Ken

--------------------------

"TS" <TS@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
I configured a data adapter and generated a dataset and wrote the code to
fill the dataset with data coming from an SQL database table when my form
loads. I also changed the DataSource of a combo box to point to the
dataset.tablename and changed the DisplayMemebr to point at a column. After
the form loads nothing is populated in the combo box? Is there something I'm
missing. Please help
--
TS

Nov 21 '05 #4

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

Similar topics

2
by: SoftWhiteDelgiht | last post by:
Help me. I am obviously stupid! :-) I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend. I have created a combo box which is to populate with...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
0
by: Roger Odermatt | last post by:
Hello I have binding a class to a DataGridView and this class have a property from another class and this i want binding to a DataGridViewComboBoxColumn. So when i change a item in the Combo and...
1
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt;...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.