?
Solved

using datacombo control in vb.net

Posted on 2006-06-19
3
Medium Priority
?
262 Views
Last Modified: 2010-05-18
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
Comment
Question by:SandeepBhambure
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
kaliyugkaarjun earned 300 total points
ID: 16941134
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question