473,503 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with TableAdapter in VB Express

Hi,
I'm trying to fill a combobox with values from a sql table. Data
seems to be connected fine. Apparently in VB Express sqlDataAdapter
doesn't work, or at least I can't make it work. Searching the help
information, it directed me to Table Adapters instead.

Can anybody help me with correcting this code. It doesn't like the
sql statement at the end of table adapters declaration line. How do I
get a sql statement to populate table values so that I can direct them
to the combobox?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.PublishersTableAdapter.Fill(Me.PUBSDataSet.publ ishers)

Dim PubsDS As New PUBSDataSet()
Dim PubsTA As New
PUBSDataSetTableAdapters.publishersTableAdapter()= ("SELECT * FROM
publishers")

PubsTA.Fill(PubsDS.publishers)

cboPubID.DataSource = PubsDS
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"

Thanks,
Randy

Apr 5 '07 #1
6 3579
table adapters are unnecessary

ADO.net is hogwash

stick with ADO classic, write data in HTML and don't follow the trendy
'programming language of the month' paradigm


On Apr 5, 8:35 am, "Randy" <spam.eastl...@gmail.comwrote:
Hi,
I'm trying to fill a combobox with values from a sql table. Data
seems to be connected fine. Apparently in VB Express sqlDataAdapter
doesn't work, or at least I can't make it work. Searching the help
information, it directed me to Table Adapters instead.

Can anybody help me with correcting this code. It doesn't like the
sql statement at the end of table adapters declaration line. How do I
get a sql statement to populate table values so that I can direct them
to the combobox?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.PublishersTableAdapter.Fill(Me.PUBSDataSet.publ ishers)

Dim PubsDS As New PUBSDataSet()
Dim PubsTA As New
PUBSDataSetTableAdapters.publishersTableAdapter()= ("SELECT * FROM
publishers")

PubsTA.Fill(PubsDS.publishers)

cboPubID.DataSource = PubsDS
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"

Thanks,
Randy

Apr 5 '07 #2
Ignore AaronKempf; he's a troll.

Robin S.
-----------------------------
"Randy" <sp***********@gmail.comwrote in message
news:11**********************@w1g2000hsg.googlegro ups.com...
Hi,
I'm trying to fill a combobox with values from a sql table. Data
seems to be connected fine. Apparently in VB Express sqlDataAdapter
doesn't work, or at least I can't make it work. Searching the help
information, it directed me to Table Adapters instead.

Can anybody help me with correcting this code. It doesn't like the
sql statement at the end of table adapters declaration line. How do I
get a sql statement to populate table values so that I can direct them
to the combobox?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.PublishersTableAdapter.Fill(Me.PUBSDataSet.publ ishers)

Dim PubsDS As New PUBSDataSet()
Dim PubsTA As New
PUBSDataSetTableAdapters.publishersTableAdapter()= ("SELECT * FROM
publishers")

PubsTA.Fill(PubsDS.publishers)

cboPubID.DataSource = PubsDS
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"

Thanks,
Randy

Apr 6 '07 #3
I am not a troll

I just speak for truth

Jihad against Microsoft; not all change is good
not all change is trendy

I won't change languages 'just because it's trendy thing to do'


On Apr 5, 11:00 pm, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Ignore AaronKempf; he's a troll.

Robin S.
-----------------------------"Randy" <spam.eastl...@gmail.comwrote in message

news:11**********************@w1g2000hsg.googlegro ups.com...
Hi,
I'm trying to fill a combobox with values from a sql table. Data
seems to be connected fine. Apparently in VB Express sqlDataAdapter
doesn't work, or at least I can't make it work. Searching the help
information, it directed me to Table Adapters instead.
Can anybody help me with correcting this code. It doesn't like the
sql statement at the end of table adapters declaration line. How do I
get a sql statement to populate table values so that I can direct them
to the combobox?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.PublishersTableAdapter.Fill(Me.PUBSDataSet.publ ishers)
Dim PubsDS As New PUBSDataSet()
Dim PubsTA As New
PUBSDataSetTableAdapters.publishersTableAdapter()= ("SELECT * FROM
publishers")
PubsTA.Fill(PubsDS.publishers)
cboPubID.DataSource = PubsDS
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"
Thanks,
Randy- Hide quoted text -

- Show quoted text -

Apr 6 '07 #4
Grrrrrrrrrrr.....

Apr 7 '07 #5

Table adapters are used with strongly typed datasets. You design these
through the Data Designer. That doesn't seem like what you are doing. It
sounds like you just want to read the database, get a table of data, and
bind it to your combobox. Is that right?

If so, try something like this:

Dim dt as DataTable

Using cn as New SqlConnection(myConnectionString)

cn.Open()

'Define the SQL Command object
Dim cmd As SqlCommand = New SqlCommand()
cmd.Connection = cn
cmd.ComandType = CommandType.Text
cmd.CommandText = ""SELECT * FROM publishers"

Dim da As SqlDataAdapter = new SqlDataAdapter(cmd)
dt = New DataTable()
da.Fill(dt)

End Using 'This closes the connection

cboPubID.DataSource = dt
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"

Robin S.
----------------------
"Randy" <sp***********@gmail.comwrote in message
news:11**********************@w1g2000hsg.googlegro ups.com...
Hi,
I'm trying to fill a combobox with values from a sql table. Data
seems to be connected fine. Apparently in VB Express sqlDataAdapter
doesn't work, or at least I can't make it work. Searching the help
information, it directed me to Table Adapters instead.

Can anybody help me with correcting this code. It doesn't like the
sql statement at the end of table adapters declaration line. How do I
get a sql statement to populate table values so that I can direct them
to the combobox?

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.PublishersTableAdapter.Fill(Me.PUBSDataSet.publ ishers)

Dim PubsDS As New PUBSDataSet()
Dim PubsTA As New
PUBSDataSetTableAdapters.publishersTableAdapter()= ("SELECT * FROM
publishers")

PubsTA.Fill(PubsDS.publishers)

cboPubID.DataSource = PubsDS
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"

Thanks,
Randy

Apr 7 '07 #6
wow... that is funny

do you know how many lines of code it takes me to build a databound
combo box?

UH ZERO?

On Apr 7, 12:33 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
Table adapters are used with strongly typed datasets. You design these
through the Data Designer. That doesn't seem like what you are doing. It
sounds like you just want to read the database, get a table of data, and
bind it to your combobox. Is that right?

If so, try something like this:

Dim dt as DataTable

Using cn as New SqlConnection(myConnectionString)

cn.Open()

'Define the SQL Command object
Dim cmd As SqlCommand = New SqlCommand()
cmd.Connection = cn
cmd.ComandType = CommandType.Text
cmd.CommandText = ""SELECT * FROM publishers"

Dim da As SqlDataAdapter = new SqlDataAdapter(cmd)
dt = New DataTable()
da.Fill(dt)

End Using 'This closes the connection

cboPubID.DataSource = dt
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"

Robin S.
----------------------"Randy" <spam.eastl...@gmail.comwrote in message

news:11**********************@w1g2000hsg.googlegro ups.com...
Hi,
I'm trying to fill a combobox with values from a sql table. Data
seems to be connected fine. Apparently in VB Express sqlDataAdapter
doesn't work, or at least I can't make it work. Searching the help
information, it directed me to Table Adapters instead.
Can anybody help me with correcting this code. It doesn't like the
sql statement at the end of table adapters declaration line. How do I
get a sql statement to populate table values so that I can direct them
to the combobox?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.PublishersTableAdapter.Fill(Me.PUBSDataSet.publ ishers)
Dim PubsDS As New PUBSDataSet()
Dim PubsTA As New
PUBSDataSetTableAdapters.publishersTableAdapter()= ("SELECT * FROM
publishers")
PubsTA.Fill(PubsDS.publishers)
cboPubID.DataSource = PubsDS
cboPubID.ValueMember = "pub_id"
cboPubID.DisplayMember = "pub_name"
Thanks,
Randy

Apr 9 '07 #7

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

Similar topics

5
7533
by: Programatix | last post by:
Hi, Have anyone ever benchmark the TableAdapter performance compared to DataTable's Load method? I found out that the DataTable's Load method is about 10x faster than TableAdapter's Fill method....
3
7189
by: Mike | last post by:
Dear Group, When I add a DataTable to a Typed Dataset, and a TableAdapter to the DataTable, I am able to create methods to send updates directly to the database (GenerateDBDirectMethods),...
0
1353
by: rpuertas | last post by:
Hello, Visual Web Developer 2005 Express Edition and SQL Server 2005 Express: I want to run a paged query within a TableAdapter. In the TableAdapter Query Configuration Wizard" I write the next...
5
1250
by: matthewtec | last post by:
I realize there are probably many discussions on these two... whether to get now or wait or yadda yadda yadda. My question is that I can continuing training on visual studio.net 2003, and...
1
4531
by: Demetri | last post by:
I have a question / concern regarding the new suggested way of creating a data access layer in an n-tier application. Typically, a web application specifically, using the SOA (Service Oriented...
2
1742
by: GaryDean | last post by:
I'm comparing use of DataView -ObjectDataSource -TableAdapter to DataView -SqlDataSource using the Customers table on the NorthWind database. The SQL given to both wizards is: SELECT ...
2
3975
by: googlegroups.dsbl | last post by:
I'm really confused here, and am wondering if someone knows what could be the issue with my TableAdapter query. A few months ago, I created a really neat program that has th ability to search by...
3
18797
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I'm not really sure how to ask this question because I'm still getting my feet wet with data access and VB.NET, but here goes: To start off with, I'm using VB 2005 Express to connect to an Access...
8
1260
by: SAL | last post by:
Hello, Using the designer in my project, I created a DataTable for one of the tables in an Access database. I created a TableAdapter for that DataTable by adding queries. For the most part, the...
0
7207
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
7093
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
7468
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
5598
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
4690
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...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
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 ...
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.