Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / April 2007

Tip: Looking for answers? Try searching our database.

Help with TableAdapter in VB Express

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Randy - 05 Apr 2007 16:35 GMT
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.publishers)

       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
aaron.kempf@gmail.com - 06 Apr 2007 00:18 GMT
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

> Hi,
> I'm trying to fill a combobox with values from a sql table.  Data
[quoted text clipped - 24 lines]
> Thanks,
> Randy
RobinS - 06 Apr 2007 07:00 GMT
Ignore AaronKempf; he's a troll.

Robin S.
-----------------------------
> Hi,
> I'm trying to fill a combobox with values from a sql table.  Data
[quoted text clipped - 24 lines]
> Thanks,
> Randy
aaron.kempf@gmail.com - 06 Apr 2007 22:22 GMT
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'

> Ignore AaronKempf; he's a troll.
>
[quoted text clipped - 30 lines]
>
> - Show quoted text -
Randy - 07 Apr 2007 05:07 GMT
Grrrrrrrrrrr.....
RobinS - 07 Apr 2007 08:33 GMT
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.
----------------------
> Hi,
> I'm trying to fill a combobox with values from a sql table.  Data
[quoted text clipped - 24 lines]
> Thanks,
> Randy
aaron.kempf@gmail.com - 09 Apr 2007 15:27 GMT
wow... that is funny

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

UH ZERO?

> 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
[quoted text clipped - 55 lines]
> > Thanks,
> > Randy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.