• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

using datacombo control in vb.net

i am using data combo control in vb6 from last few years. Now i have shifted to vb.net and i want  to make use of data combo. Please help me on how to use it, with code as i am not getting the expected result.
I have tried using it but it gives me typecasting error.

0
SandeepBhambure
Asked:
SandeepBhambure
1 Solution
 
kaliyugkaarjunCommented:
Just add a combo box to a form and add the following code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim cmdString As String = "Select * from Employees"
Dim connString As String = "user id=sa;password=;database=northwind;server=MCB"
Dim myConnection As SqlConnection = New SqlConnection(connString)

Try
' Open connection
myConnection.Open()
Dim da As SqlDataAdapter = New SqlDataAdapter(cmdString, myConnection)
Dim dataSet1 As DataSet = New DataSet()
da.Fill(dataSet1, "Employees")
Dim DataViewManager1 As DataViewManager = dataSet1.DefaultViewManager
ComboBox1.DataSource = DataViewManager1
ComboBox1.DisplayMember = "Employees.FirstName"

Catch ae As SqlException
MessageBox.Show(ae.Message)
End Try
End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now