RotorTorque
Programmer
Hi all,
I am using the following code in my VB.Net 2005 application to get data into a DataSet and then load a combobox:
The ComboBox needs to be refreshed constantly. I am already clearing the ComboBox and setting its DataSource to Nothing. But items keep getting added to the Combobox. I think I need to Drop the table from the DataSet first and then add it again. How can I remove the table from the DataSet?
Thanks in advance,
RotorTorque
I am using the following code in my VB.Net 2005 application to get data into a DataSet and then load a combobox:
Code:
Public Sub GetSubType(ByVal cbo As ComboBox, ByVal intX As Integer)
Dim SQLConn As New SqlClient.SqlConnection
SQLConn = New SqlClient.SqlConnection
SQLConn.ConnectionString = My.Settings.HelpDeskConnectionString
SQLConn.Open()
'Declare a SQL DataAdapter object
Dim objDataAdapter As New SqlDataAdapter()
'Assign a new SQLCommand to the SelectCommand property
objDataAdapter.SelectCommand = New SqlCommand
'Set the SelectCommand properties...
objDataAdapter.SelectCommand.Connection = SQLConn
objDataAdapter.SelectCommand.CommandText = "SELECT CaseSubType FROM CaseSubType WHERE(CaseTypeID = '" & intX & "')"
objDataAdapter.Fill(objDataSet, "Sub Types")
SQLConn.Close()
cbo.DataSource = Nothing
cbo.Items.Clear()
cbo.DataSource = objDataSet.Tables("Sub Types")
cbo.DisplayMember = "CaseSubType"
'Clean Up
objDataAdapter = Nothing
SQLConn = Nothing
End Sub
The ComboBox needs to be refreshed constantly. I am already clearing the ComboBox and setting its DataSource to Nothing. But items keep getting added to the Combobox. I think I need to Drop the table from the DataSet first and then add it again. How can I remove the table from the DataSet?
Thanks in advance,
RotorTorque