The code below is creating the SQLDataAdapter, DataSet, and SQLCommand
objects inside the method that handles the button click event, which by
itself isn't a problem, but because the object variables are scoped to
that method, they'll be destroyed when the method finishes. If you
instead scope the object variables to the form, the objects won't be
destroyed until the form closes, and the method should work as you're
expecting it to work.
Hope this helps ...
Larry Kurtze
Aspacia Systems Inc
866.566.9600
312.803.0730 Fax
www.aspacia.com
lkurtze@...
-----Original Message-----
From: Leonard, Jeremy [mailto:jleonard@...]
Sent: Wednesday, July 30, 2003 2:30 PM
To: 'vantage@yahoogroups.com'
Subject: [Vantage] VB.NET and ADO.NET
Hello, Does anyone here work with ADO.NET in VB.NET? I am converting my
first application.
I am trying to populate the contents of a dropdown list box. I am using
a
dropdown box from ComponentOne but I have the same problem with the
standard
vb.net combobox. Useing the additem method of the combo box's
collection I
am able to populate the combo box but it is very slow because there are
thousands of items to add. I would like to bind this combo box to a
dataset
but I am missing something. If anyone knows where I am going wrong,
please
help. FYI, I am connection to a SQL Server table named PUB_Part. The
string stConnection contains the connection string which I have stated
in
the on load event of my startup form.
Thanks
Jeremy Leonard
IT Manager
K-T Corporation
Private Sub btnLoadComboData_Click(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles btnLoadComboData.Click
Dim stItemData As String = "SELECT partnum From PUB_Part ORDER
BY
partnum" 'creates the select statment
Dim daItemdata As New SqlDataAdapter()
Dim dsItemdata As New DataSet()
Dim cmdItemdata As SqlCommand = New SqlCommand(stItemData,
connSQLData1)
daItemdata.SelectCommand = cmdItemdata
connSQLData1.ConnectionString = stConnection
connSQLData1.Open()
daItemdata.Fill(dsItemdata, "PUB_Part")
cmbItemData.DataSource = dsItemdata
cmbItemData.DataMember = "PartNum"
connSQLData1.Close()
End Sub
Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder
and Crystal Reports and other 'goodies', please goto:
http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto:
http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto:
http://groups.yahoo.com/group/vantage/links
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
objects inside the method that handles the button click event, which by
itself isn't a problem, but because the object variables are scoped to
that method, they'll be destroyed when the method finishes. If you
instead scope the object variables to the form, the objects won't be
destroyed until the form closes, and the method should work as you're
expecting it to work.
Hope this helps ...
Larry Kurtze
Aspacia Systems Inc
866.566.9600
312.803.0730 Fax
www.aspacia.com
lkurtze@...
-----Original Message-----
From: Leonard, Jeremy [mailto:jleonard@...]
Sent: Wednesday, July 30, 2003 2:30 PM
To: 'vantage@yahoogroups.com'
Subject: [Vantage] VB.NET and ADO.NET
Hello, Does anyone here work with ADO.NET in VB.NET? I am converting my
first application.
I am trying to populate the contents of a dropdown list box. I am using
a
dropdown box from ComponentOne but I have the same problem with the
standard
vb.net combobox. Useing the additem method of the combo box's
collection I
am able to populate the combo box but it is very slow because there are
thousands of items to add. I would like to bind this combo box to a
dataset
but I am missing something. If anyone knows where I am going wrong,
please
help. FYI, I am connection to a SQL Server table named PUB_Part. The
string stConnection contains the connection string which I have stated
in
the on load event of my startup form.
Thanks
Jeremy Leonard
IT Manager
K-T Corporation
Private Sub btnLoadComboData_Click(ByVal sender As System.Object, ByVal
e As
System.EventArgs) Handles btnLoadComboData.Click
Dim stItemData As String = "SELECT partnum From PUB_Part ORDER
BY
partnum" 'creates the select statment
Dim daItemdata As New SqlDataAdapter()
Dim dsItemdata As New DataSet()
Dim cmdItemdata As SqlCommand = New SqlCommand(stItemData,
connSQLData1)
daItemdata.SelectCommand = cmdItemdata
connSQLData1.ConnectionString = stConnection
connSQLData1.Open()
daItemdata.Fill(dsItemdata, "PUB_Part")
cmbItemData.DataSource = dsItemdata
cmbItemData.DataMember = "PartNum"
connSQLData1.Close()
End Sub
Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder
and Crystal Reports and other 'goodies', please goto:
http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto:
http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto:
http://groups.yahoo.com/group/vantage/links
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/