Fill Combo From Databsse

nido12

Member
Joined
Dec 12, 2005
Messages
5
Programming Experience
1-3
Dear all VB.Net Helpers:cool: ,

I have a question in a proj am doin:confused:

is it possible to fill a combo from a database(am using acess) and i want in this combo to show two fields of a table in the database

my table is employee and i want to show in the same combo both the first and last name of the employee,is that possible?:confused:

Hope To get A response as as soon as possible:rolleyes: ...

Thank you:D
Regards,
Me:)

n.b:txtreport is the combo name


this is the code am using below :

' Fill the combobox
Dim pDataAdapter As OleDb.OleDbDataAdapter
Dim pDataSet As DataSet
pDataAdapter = New OleDb.OleDbDataAdapter(New OleDb.OleDbCommand( _
"SELECT FirstName,LastName FROM Employees ", mConn))
pDataSet = New DataSet
Try
pDataAdapter.Fill(pDataSet)
Catch eror As Exception
MsgBox(eror.Message)
End Try
txtreport.DataSource = pDataSet.Tables(0)
txtreport.DisplayMember = "FirstName"

 
It's not possible to show more than one column in a standard ComboBox. Your options are to create an additional column in your DataTable that contains the two names concatenated, or else use a custom ComboBox that supports multiple columns. If you want to take the second option then I'd suggest a search at The Code Project.
 
jmcilhinney said:
Moved to more appropriate forum.
I already moved this thread from the VS.NET General forum and you've gone and reposted the same question in that same forum. Please DO NOT create duplicate threads and please post your questions in the most appropriate forum. The VS.NET General forum is for general questions regarding the Visual Studio or Visual Basic IDE. This question specifically relates to Windows Forms, which is why I moved it here. Your other thread has been deleted.
 
Back
Top