Solved

using datacombo control in vb.net

Posted on 2006-06-19
3
247 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
3 Comments
 
LVL 8

Accepted Solution

by:
kaliyugkaarjun earned 75 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now