My problem is

Am using SQL SERVER as database with VB.NET as Front End.

I do have a database Known as Trackers with a Table known as Emp
In Emp,I have the fields as Name,Surname,Emp_ID,Address.

Here I have made the Emp_ID in the database..its Identity to "Yes"..so that the database automatically generates unique number.

I have a combobox named Cmb_EmpName and it contains the Name of the Employees(ie both the Name and Surname together)....suppose in the database i have two same names...ie eg: Tom Alex and Emp_ID=12, and another row Tom Alex and Emp_ID=13 (Here Emp_ID is being automatically generated...)

so in the Combo box named Cmb_EmpName,it will populate two names...ie Tom Alex
Tom Alex

When I click on Tom Alex,ie the sescond one,it takes only the first.

In Visual Basic, I know how to do.

Code in Visual Basic

In the FormLoad

Dim cnn As New ADODB.Connection
Dim rs1 As ADODB.Recordset
Dim i As Integer

Set cnn = New ADODB.Connection
cnn.Open "DSN=Telemanagement;uid=sa;pwd=sa"
Set rs1 = New ADODB.Recordset
rs1.Open "SELECT Emp_ID,Emp_Name+' '+Emp_Surname as Name from Employees", cnn, adOpenStatic, adLockReadOnly

Do While Not rs1.EOF
Cmb_EmpName.AddItem rs1.Fields("Name").Value
Cmb_EmpName.ItemData(Cmb_EmpName.NewIndex) = rs1.Fields("Emp_ID")// Here is where we are storing every value of Emp_ID to the corresponding Name

so that if there are more than one same names,i can click any names because the Emp_ID is unique for each rows.
ie Tom Alex With Emp_ID 12


Tom Alex With Emp_ID 13

Like Wise in VB.NET..is there any code for this line

ie Cmb_EmpName.ItemData(Cmb_EmpName.NewIndex)=rs1.Fields("Emp_ID")

because in VB.NET,I couldn't find a property known as ItemData or New Index....In VB.NET there is only Items,Selected Index,Selected Items,Select..

Is there any similiar words like ItemData,New Index of Visual Basic in that of the VB.NET

So can anyone help me out of this problem....

I know am putting too much trouble on you guys..sorry but thanks lot



chek for lastindex...

or else use the following :
dim i
i=combobox1. Items.count
the count has the highest index + 1 of your combo's items....

further help, mail at pwy_20002001@yahoo.co.in with full code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.