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
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