How do I store Unique Values to More than One Same Names in Database using VB.NET

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2006
Posts: 13
Reputation: B.H is an unknown quantity at this point 
Solved Threads: 0
B.H B.H is offline Offline
Newbie Poster

How do I store Unique Values to More than One Same Names in Database using VB.NET

 
0
  #1
Aug 24th, 2006
Hi,

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
rs1.MoveNext
Loop

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

or

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

Cheers

B.H
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 5
Reputation: jaay is an unknown quantity at this point 
Solved Threads: 0
jaay jaay is offline Offline
Newbie Poster

Re: How do I store Unique Values to More than One Same Names in Database using VB.NET

 
0
  #2
Sep 7th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC